Bug 1417554 - Use module level test functions instead of unittest.TestCase classes. r?ahal draft
authorDave Hunt <dhunt@mozilla.com>
Thu, 16 Nov 2017 11:09:13 +0000
changeset 699026 29c260c5abe7fbbcc61adffcef5ccd7911b7560d
parent 699025 da7fd451e3f9eef20a94dc350b3f9583f202b510
child 699027 0d45e497825b323dd863989d7627ba21ecf923d1
push id89432
push userbmo:dave.hunt@gmail.com
push dateThu, 16 Nov 2017 11:22:46 +0000
reviewersahal
bugs1417554
milestone59.0a1
Bug 1417554 - Use module level test functions instead of unittest.TestCase classes. r?ahal MozReview-Commit-ID: G3JXMqUWNmT
testing/mozbase/moznetwork/tests/test.py
--- a/testing/mozbase/moznetwork/tests/test.py
+++ b/testing/mozbase/moznetwork/tests/test.py
@@ -5,17 +5,16 @@ Unit-Tests for moznetwork
 
 from __future__ import absolute_import
 
 import mock
 import mozinfo
 import moznetwork
 import re
 import subprocess
-import unittest
 from distutils.spawn import find_executable
 
 import mozunit
 
 
 def verify_ip_in_list(ip):
     """
     Helper Method to check if `ip` is listed in Network Adresses
@@ -60,37 +59,36 @@ def verify_ip_in_list(ip):
 
     # Check if ip is in list
     if ip in ip_list:
         return True
     else:
         return False
 
 
-class TestGetIP(unittest.TestCase):
+def test_get_ip():
+    """ Attempt to test the IP address returned by
+    moznetwork.get_ip() is valid """
 
-    def test_get_ip(self):
-        """ Attempt to test the IP address returned by
-        moznetwork.get_ip() is valid """
+    ip = moznetwork.get_ip()
 
-        ip = moznetwork.get_ip()
+    # Check the IP returned by moznetwork is in the list
+    assert verify_ip_in_list(ip)
 
-        # Check the IP returned by moznetwork is in the list
-        assert verify_ip_in_list(ip)
 
-    def test_get_ip_using_get_interface(self):
-        """ Test that the control flow path for get_ip() using
-        _get_interface_list() is works """
+def test_get_ip_using_get_interface():
+    """ Test that the control flow path for get_ip() using
+    _get_interface_list() is works """
 
-        if mozinfo.isLinux or mozinfo.isMac:
+    if mozinfo.isLinux or mozinfo.isMac:
 
-            with mock.patch('socket.gethostbyname') as byname:
-                # Force socket.gethostbyname to return None
-                byname.return_value = None
+        with mock.patch('socket.gethostbyname') as byname:
+            # Force socket.gethostbyname to return None
+            byname.return_value = None
 
-                ip = moznetwork.get_ip()
+            ip = moznetwork.get_ip()
 
-                # Check the IP returned by moznetwork is in the list
-                assert verify_ip_in_list(ip)
+            # Check the IP returned by moznetwork is in the list
+            assert verify_ip_in_list(ip)
 
 
 if __name__ == '__main__':
     mozunit.main()