From 0877060f8690c50865c3840585c6ce285a99c07c Mon Sep 17 00:00:00 2001 From: Michael Foord Date: Sat, 6 Feb 2010 00:22:26 +0000 Subject: unittest.TestLoader creates a TestSuite before calling load_tests. Issue 7799. --- Lib/test/test_unittest.py | 2 ++ Lib/unittest/loader.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_unittest.py b/Lib/test/test_unittest.py index f24117c..8314262 100644 --- a/Lib/test/test_unittest.py +++ b/Lib/test/test_unittest.py @@ -272,12 +272,14 @@ class Test_TestLoader(TestCase): load_tests_args = [] def load_tests(loader, tests, pattern): + self.assertIsInstance(tests, unittest.TestSuite) load_tests_args.extend((loader, tests, pattern)) return tests m.load_tests = load_tests loader = unittest.TestLoader() suite = loader.loadTestsFromModule(m) + self.assertIsInstance(suite, unittest.TestSuite) self.assertEquals(load_tests_args, [loader, suite, None]) load_tests_args = [] diff --git a/Lib/unittest/loader.py b/Lib/unittest/loader.py index 31c343b..c04de06 100644 --- a/Lib/unittest/loader.py +++ b/Lib/unittest/loader.py @@ -71,9 +71,10 @@ class TestLoader(object): tests.append(self.loadTestsFromTestCase(obj)) load_tests = getattr(module, 'load_tests', None) + tests = self.suiteClass(tests) if use_load_tests and load_tests is not None: return load_tests(self, tests, None) - return self.suiteClass(tests) + return tests def loadTestsFromName(self, name, module=None): """Return a suite of all tests cases given a string specifier. -- cgit v0.12