Commits

Anonymous committed 0d8f20e

unittest.TestLoader creates a TestSuite before calling load_tests. Issue 7799.

Comments (0)

Files changed (2)

Lib/test/test_unittest.py

 
         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 = []

Lib/unittest/loader.py

                 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.