mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	unittest.TestLoader creates a TestSuite before calling load_tests. Issue 7799.
This commit is contained in:
		
							parent
							
								
									2373926964
								
							
						
					
					
						commit
						0877060f86
					
				
					 2 changed files with 4 additions and 1 deletions
				
			
		|  | @ -272,12 +272,14 @@ def test(self): | |||
| 
 | ||||
|         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 = [] | ||||
|  |  | |||
|  | @ -71,9 +71,10 @@ def loadTestsFromModule(self, module, use_load_tests=True): | |||
|                 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. | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Michael Foord
						Michael Foord