Bug 1472199 - [mozbuild] Remove unittest dependency from test_pythonutil.py and narrow to tests module; r?ahal draft
authorDave Hunt <dhunt@mozilla.com>
Thu, 05 Jul 2018 14:27:29 +0100
changeset 814489 8bbd3447861fc4bdd810e646855a35ea1552d7c4
parent 813581 a0e47ebc4c06e652b919dabee711fdbd6bfd31b5
child 814490 2507d31eb41ec912a3706ea09adad35575fdf719
push id115231
push userbmo:dave.hunt@gmail.com
push dateThu, 05 Jul 2018 13:44:38 +0000
reviewersahal
bugs1472199
milestone63.0a1
Bug 1472199 - [mozbuild] Remove unittest dependency from test_pythonutil.py and narrow to tests module; r?ahal The test checks the modules imported, which means it will fail if we import mozbuild.base to determine the topsrcdir. Rather than include the additional modules, which may change in the future, I have narrowed the scope of the test to the mozbuild/tests module. MozReview-Commit-ID: GiaPzp19adE
python/mozbuild/mozbuild/test/test_pythonutil.py
--- a/python/mozbuild/mozbuild/test/test_pythonutil.py
+++ b/python/mozbuild/mozbuild/test/test_pythonutil.py
@@ -1,24 +1,20 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from mozbuild.pythonutil import iter_modules_in_path
 from mozunit import main
 import os
-import unittest
 
 
-class TestIterModules(unittest.TestCase):
-    def test_iter_modules_in_path(self):
-        mozbuild_path = os.path.normcase(os.path.dirname(os.path.dirname(__file__)))
-        paths = list(iter_modules_in_path(mozbuild_path))
-        self.assertEquals(set(paths), set([
-            os.path.join(os.path.abspath(mozbuild_path), '__init__.py'),
-            os.path.join(os.path.abspath(mozbuild_path), 'pythonutil.py'),
-            os.path.join(os.path.abspath(mozbuild_path), 'test', '__init__.py'),
-            os.path.join(os.path.abspath(mozbuild_path), 'test', 'test_pythonutil.py'),
-        ]))
+def test_iter_modules_in_path():
+    tests_path = os.path.normcase(os.path.dirname(__file__))
+    paths = list(iter_modules_in_path(tests_path))
+    assert set(paths) == set([
+        os.path.join(os.path.abspath(tests_path), '__init__.py'),
+        os.path.join(os.path.abspath(tests_path), 'test_pythonutil.py'),
+    ])
 
 
 if __name__ == '__main__':
     main()