From Dan Kenigsberg danken@redhat.com:
Dan Kenigsberg has posted comments on this change.
Change subject: tests: Avoid global state modification using forked ......................................................................
Patch Set 1:
(2 comments)
https://gerrit.ovirt.org/#/c/67338/1/tests/moduleloader_test.py File tests/moduleloader_test.py:
Line 39: for f in files: Line 40: utils.touchFile(os.path.join(path, f)) Line 41: utils.touchFile(os.path.join(path, '__init__.py')) Line 42: sys.path.append(os.path.dirname(path)) Line 43: yield importlib.import_module(os.path.basename(path))
If we run each test in a new child process, we don't need to clean anything
this is true for all tests. Still, we care to use MonkeyPatch to clean after ourselves! Line 44: Line 45: @permutations( Line 46: [(('a.py', 'b.py'), ('a', 'b')), Line 47: (('a.py', 'b.py', 'a.pyc', 'a.pyioas'), ('a', 'b')),
Line 47: (('a.py', 'b.py', 'a.pyc', 'a.pyioas'), ('a', 'b')), Line 48: (('a.py', 'b.py', 'a.pyc', 'a.py'), ('a', 'b')), Line 49: (('a.py', 'b.py', 'a.pyc', '_my.py'), ('a', 'b', '_my'))] Line 50: ) Line 51: @forked
Importing stuff into python leave traces in sys.modules that are not easy (
I'm anxious to see Travis green, and thank you for all these cleanups. I simply don't understand how the traceback that we see is related to a stale sys.path, so this patch seems a bit of black magic to me...
Yes, I'd love to mark that test as broken (but the patch doing it is high on a chain of other fixes) Line 52: def test_import_modules(self, files, expected_modules): Line 53: with self._setup_test_modules(files) as module_name: Line 54: result = moduleloader.load_modules(module_name) Line 55:
vdsm-patches@lists.fedorahosted.org