Fix ResourceWarning in test_unittest when interrupted

This commit is contained in:
Victor Stinner 2016-03-30 01:15:28 +02:00
parent 06ddd35f5f
commit 9db2ae7263
1 changed files with 6 additions and 3 deletions

View File

@ -290,6 +290,7 @@ class Test_TextTestRunner(unittest.TestCase):
# no args -> all the warnings are printed, unittest warnings only once
p = subprocess.Popen([sys.executable, '_test_warnings.py'], **opts)
with p:
out, err = get_parse_out_err(p)
self.assertIn(b'OK', err)
# check that the total number of warnings in the output is correct
@ -311,6 +312,7 @@ class Test_TextTestRunner(unittest.TestCase):
# in all these cases no warnings are printed
for args in args_list:
p = subprocess.Popen(args, **opts)
with p:
out, err = get_parse_out_err(p)
self.assertIn(b'OK', err)
self.assertEqual(len(out), 0)
@ -320,6 +322,7 @@ class Test_TextTestRunner(unittest.TestCase):
# unittest warnings only once
p = subprocess.Popen([sys.executable, '_test_warnings.py', 'always'],
**opts)
with p:
out, err = get_parse_out_err(p)
self.assertIn(b'OK', err)
self.assertEqual(len(out), 14)