mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 07:31:38 +00:00 
			
		
		
		
	Fix ResourceWarning in test_unittest when interrupted
This commit is contained in:
		
							parent
							
								
									06ddd35f5f
								
							
						
					
					
						commit
						9db2ae7263
					
				
					 1 changed files with 6 additions and 3 deletions
				
			
		| 
						 | 
					@ -290,7 +290,8 @@ def get_parse_out_err(p):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # no args -> all the warnings are printed, unittest warnings only once
 | 
					        # no args -> all the warnings are printed, unittest warnings only once
 | 
				
			||||||
        p = subprocess.Popen([sys.executable, '_test_warnings.py'], **opts)
 | 
					        p = subprocess.Popen([sys.executable, '_test_warnings.py'], **opts)
 | 
				
			||||||
        out, err = get_parse_out_err(p)
 | 
					        with p:
 | 
				
			||||||
 | 
					            out, err = get_parse_out_err(p)
 | 
				
			||||||
        self.assertIn(b'OK', err)
 | 
					        self.assertIn(b'OK', err)
 | 
				
			||||||
        # check that the total number of warnings in the output is correct
 | 
					        # check that the total number of warnings in the output is correct
 | 
				
			||||||
        self.assertEqual(len(out), 12)
 | 
					        self.assertEqual(len(out), 12)
 | 
				
			||||||
| 
						 | 
					@ -311,7 +312,8 @@ def get_parse_out_err(p):
 | 
				
			||||||
        # in all these cases no warnings are printed
 | 
					        # in all these cases no warnings are printed
 | 
				
			||||||
        for args in args_list:
 | 
					        for args in args_list:
 | 
				
			||||||
            p = subprocess.Popen(args, **opts)
 | 
					            p = subprocess.Popen(args, **opts)
 | 
				
			||||||
            out, err = get_parse_out_err(p)
 | 
					            with p:
 | 
				
			||||||
 | 
					                out, err = get_parse_out_err(p)
 | 
				
			||||||
            self.assertIn(b'OK', err)
 | 
					            self.assertIn(b'OK', err)
 | 
				
			||||||
            self.assertEqual(len(out), 0)
 | 
					            self.assertEqual(len(out), 0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -320,7 +322,8 @@ def get_parse_out_err(p):
 | 
				
			||||||
        #                                     unittest warnings only once
 | 
					        #                                     unittest warnings only once
 | 
				
			||||||
        p = subprocess.Popen([sys.executable, '_test_warnings.py', 'always'],
 | 
					        p = subprocess.Popen([sys.executable, '_test_warnings.py', 'always'],
 | 
				
			||||||
                             **opts)
 | 
					                             **opts)
 | 
				
			||||||
        out, err = get_parse_out_err(p)
 | 
					        with p:
 | 
				
			||||||
 | 
					            out, err = get_parse_out_err(p)
 | 
				
			||||||
        self.assertIn(b'OK', err)
 | 
					        self.assertIn(b'OK', err)
 | 
				
			||||||
        self.assertEqual(len(out), 14)
 | 
					        self.assertEqual(len(out), 14)
 | 
				
			||||||
        for msg in [b'dw', b'iw', b'uw', b'rw']:
 | 
					        for msg in [b'dw', b'iw', b'uw', b'rw']:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue