Browse Source

tests: fix loading tests for templates

Fix #209
Marek Marczykowski-Górecki 5 năm trước cách đây
mục cha
commit
f8d17012c3

+ 2 - 2
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

+ 1 - 1
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

+ 4 - 2
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
 

+ 3 - 1
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

+ 1 - 1
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