Index: Lib/unittest/test/test_runner.py =================================================================== --- Lib/unittest/test/test_runner.py (revision 86934) +++ Lib/unittest/test/test_runner.py (working copy) @@ -265,6 +265,8 @@ # no args -> all the warnings are printed, unittest warnings only once p = subprocess.Popen([sys.executable, '_test_warnings.py'], **opts) + self.addCleanup(p.stdout.close) + self.addCleanup(p.stderr.close) out, err = get_parse_out_err(p) self.assertIn(b'OK', err) # check that the total number of warnings in the output is correct @@ -286,6 +288,8 @@ # in all these cases no warnings are printed for args in args_list: p = subprocess.Popen(args, **opts) + self.addCleanup(p.stdout.close) + self.addCleanup(p.stderr.close) out, err = get_parse_out_err(p) self.assertIn(b'OK', err) self.assertEqual(len(out), 0) @@ -295,6 +299,8 @@ # unittest warnings only once p = subprocess.Popen([sys.executable, '_test_warnings.py', 'always'], **opts) + self.addCleanup(p.stdout.close) + self.addCleanup(p.stderr.close) out, err = get_parse_out_err(p) self.assertIn(b'OK', err) self.assertEqual(len(out), 14)