[Python-checkins] cpython (3.5): Fix ResourceWarning in test_unittest when interrupted
victor.stinner
python-checkins at python.org
Tue Mar 29 19:16:10 EDT 2016
https://hg.python.org/cpython/rev/f75d78a59601
changeset: 100789:f75d78a59601
branch: 3.5
parent: 100787:c38ac7ab8d9a
user: Victor Stinner <victor.stinner at gmail.com>
date: Wed Mar 30 01:15:28 2016 +0200
summary:
Fix ResourceWarning in test_unittest when interrupted
files:
Lib/unittest/test/test_runner.py | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/Lib/unittest/test/test_runner.py b/Lib/unittest/test/test_runner.py
--- a/Lib/unittest/test/test_runner.py
+++ b/Lib/unittest/test/test_runner.py
@@ -290,7 +290,8 @@
# no args -> all the warnings are printed, unittest warnings only once
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)
# check that the total number of warnings in the output is correct
self.assertEqual(len(out), 12)
@@ -311,7 +312,8 @@
# in all these cases no warnings are printed
for args in args_list:
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.assertEqual(len(out), 0)
@@ -320,7 +322,8 @@
# unittest warnings only once
p = subprocess.Popen([sys.executable, '_test_warnings.py', 'always'],
**opts)
- out, err = get_parse_out_err(p)
+ with p:
+ out, err = get_parse_out_err(p)
self.assertIn(b'OK', err)
self.assertEqual(len(out), 14)
for msg in [b'dw', b'iw', b'uw', b'rw']:
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list