mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	bpo-33746: Fix test_unittest.testRegisterResult() in verbose mode (GH-7799)
Only make sure that the result is in unittest.signals._results, don't check the full content of unittest.signals._results. support._run_suite() uses TextTestRunner in verbose mode, but TextTestRunner.run() calls registerResult(result) which made the test fail with "odd object in result set". Call also removeResult() to restore unittest.signals._results to avoid test side effect.
This commit is contained in:
		
							parent
							
								
									9bb92235f6
								
							
						
					
					
						commit
						fd8fbce495
					
				
					 2 changed files with 7 additions and 9 deletions
				
			
		|  | @ -39,16 +39,13 @@ def testInstallHandler(self): | |||
| 
 | ||||
|     def testRegisterResult(self): | ||||
|         result = unittest.TestResult() | ||||
|         self.assertNotIn(result, unittest.signals._results) | ||||
| 
 | ||||
|         unittest.registerResult(result) | ||||
| 
 | ||||
|         for ref in unittest.signals._results: | ||||
|             if ref is result: | ||||
|                 break | ||||
|             elif ref is not result: | ||||
|                 self.fail("odd object in result set") | ||||
|         else: | ||||
|             self.fail("result not found") | ||||
| 
 | ||||
|         try: | ||||
|             self.assertIn(result, unittest.signals._results) | ||||
|         finally: | ||||
|             unittest.removeResult(result) | ||||
| 
 | ||||
|     def testInterruptCaught(self): | ||||
|         default_handler = signal.getsignal(signal.SIGINT) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Victor Stinner
						Victor Stinner