[Python-checkins] r78010 - in python/trunk/Lib: test/test_unittest.py unittest/loader.py

michael.foord python-checkins at python.org
Sat Feb 6 01:22:27 CET 2010


Author: michael.foord
Date: Sat Feb  6 01:22:26 2010
New Revision: 78010

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

Modified:
   python/trunk/Lib/test/test_unittest.py
   python/trunk/Lib/unittest/loader.py

Modified: python/trunk/Lib/test/test_unittest.py
==============================================================================
--- python/trunk/Lib/test/test_unittest.py	(original)
+++ python/trunk/Lib/test/test_unittest.py	Sat Feb  6 01:22:26 2010
@@ -272,12 +272,14 @@
 
         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 = []

Modified: python/trunk/Lib/unittest/loader.py
==============================================================================
--- python/trunk/Lib/unittest/loader.py	(original)
+++ python/trunk/Lib/unittest/loader.py	Sat Feb  6 01:22:26 2010
@@ -71,9 +71,10 @@
                 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.


More information about the Python-checkins mailing list