From f8d17012c3ff263fc83472dacbf8e705b7261111 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sun, 15 Jul 2018 21:57:34 +0200 Subject: [PATCH] tests: fix loading tests for templates Fix #209 --- qubes/tests/extra.py | 4 ++-- qubes/tests/integ/backup.py | 2 +- qubes/tests/integ/basic.py | 6 ++++-- qubes/tests/integ/dispvm.py | 4 +++- qubes/tests/integ/network.py | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/qubes/tests/extra.py b/qubes/tests/extra.py index 4ee6534e..d93b8cc2 100644 --- a/qubes/tests/extra.py +++ b/qubes/tests/extra.py @@ -207,10 +207,10 @@ def load_tests(loader, tests, pattern): 'qubes.tests.extra.for_template'): try: for test_case in entry.load()(): - test.addTests(loader.loadTestsFromNames( + tests.addTests(loader.loadTestsFromNames( qubes.tests.create_testcases_for_templates( test_case.__name__, test_case, - globals=sys.modules[test_case.__module__].__dict__))) + module=sys.modules[test_case.__module__]))) except Exception as err: # pylint: disable=broad-except def runTest(self): raise err diff --git a/qubes/tests/integ/backup.py b/qubes/tests/integ/backup.py index 2954e945..36b4b98b 100644 --- a/qubes/tests/integ/backup.py +++ b/qubes/tests/integ/backup.py @@ -654,5 +654,5 @@ def load_tests(loader, tests, pattern): tests.addTests(loader.loadTestsFromNames( qubes.tests.create_testcases_for_templates('TC_10_BackupVM', TC_10_BackupVMMixin, qubes.tests.SystemTestCase, - globals=globals()))) + module=sys.modules[__name__]))) return tests diff --git a/qubes/tests/integ/basic.py b/qubes/tests/integ/basic.py index 5b0eb089..534b13aa 100644 --- a/qubes/tests/integ/basic.py +++ b/qubes/tests/integ/basic.py @@ -35,6 +35,8 @@ import collections import pkg_resources import shutil +import sys + import qubes import qubes.firewall import qubes.tests @@ -796,11 +798,11 @@ def load_tests(loader, tests, pattern): tests.addTests(loader.loadTestsFromNames( qubes.tests.create_testcases_for_templates('TC_05_StandaloneVM', TC_05_StandaloneVMMixin, qubes.tests.SystemTestCase, - globals=globals()))) + module=sys.modules[__name__]))) tests.addTests(loader.loadTestsFromNames( qubes.tests.create_testcases_for_templates('TC_06_AppVM', TC_06_AppVMMixin, qubes.tests.SystemTestCase, - globals=globals()))) + module=sys.modules[__name__]))) return tests diff --git a/qubes/tests/integ/dispvm.py b/qubes/tests/integ/dispvm.py index 7b1abd71..b852d827 100644 --- a/qubes/tests/integ/dispvm.py +++ b/qubes/tests/integ/dispvm.py @@ -28,6 +28,8 @@ from distutils import spawn import asyncio +import sys + import qubes.tests class TC_04_DispVM(qubes.tests.SystemTestCase): @@ -285,5 +287,5 @@ def load_tests(loader, tests, pattern): tests.addTests(loader.loadTestsFromNames( qubes.tests.create_testcases_for_templates('TC_20_DispVM', TC_20_DispVMMixin, qubes.tests.SystemTestCase, - globals=globals()))) + module=sys.modules[__name__]))) return tests diff --git a/qubes/tests/integ/network.py b/qubes/tests/integ/network.py index 68801820..8ebb07f0 100644 --- a/qubes/tests/integ/network.py +++ b/qubes/tests/integ/network.py @@ -1330,6 +1330,6 @@ def load_tests(loader, tests, pattern): module=sys.modules[__name__]))) tests.addTests(loader.loadTestsFromNames( qubes.tests.create_testcases_for_templates('VmUpdates', - VmUpdates, qubes.tests.SystemTestCase, + VmUpdatesMixin, qubes.tests.SystemTestCase, module=sys.modules[__name__]))) return tests