summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Curtin <brian.curtin@gmail.com>2010-11-05 17:19:38 (GMT)
committerBrian Curtin <brian.curtin@gmail.com>2010-11-05 17:19:38 (GMT)
commit7fe045ef00c5bf7c6ce00ec6e2d6c88a1b570979 (patch)
tree051e93b584a66c0f57b13e805f15dc5394cc9aa7
parent91a5b818e0b1a24e8c5775922441648fc50f73ef (diff)
downloadcpython-7fe045ef00c5bf7c6ce00ec6e2d6c88a1b570979.zip
cpython-7fe045ef00c5bf7c6ce00ec6e2d6c88a1b570979.tar.gz
cpython-7fe045ef00c5bf7c6ce00ec6e2d6c88a1b570979.tar.bz2
Merged revisions 86207 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r86207 | brian.curtin | 2010-11-05 12:09:05 -0500 (Fri, 05 Nov 2010) | 2 lines Fix a number of ResourceWarnings on Windows due to open pipes. ........
-rw-r--r--Lib/test/test_subprocess.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 0d1ac87..37c4e0f 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -345,6 +345,9 @@ class ProcessTestCase(BaseTestCase):
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
+ self.addCleanup(p.stdout.close)
+ self.addCleanup(p.stderr.close)
+ self.addCleanup(p.stdin.close)
(stdout, stderr) = p.communicate("banana")
self.assertEqual(stdout, "banana")
self.assertStderrEqual(stderr, "pineapple")
@@ -393,6 +396,9 @@ class ProcessTestCase(BaseTestCase):
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
+ self.addCleanup(p.stdout.close)
+ self.addCleanup(p.stderr.close)
+ self.addCleanup(p.stdin.close)
string_to_write = "abc"*pipe_buf
(stdout, stderr) = p.communicate(string_to_write)
self.assertEqual(stdout, string_to_write)
@@ -405,6 +411,9 @@ class ProcessTestCase(BaseTestCase):
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
+ self.addCleanup(p.stdout.close)
+ self.addCleanup(p.stderr.close)
+ self.addCleanup(p.stdin.close)
p.stdin.write("banana")
(stdout, stderr) = p.communicate("split")
self.assertEqual(stdout, "bananasplit")
@@ -454,6 +463,8 @@ class ProcessTestCase(BaseTestCase):
'sys.stdout.write("\\nline6");'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
universal_newlines=1)
+ self.addCleanup(p.stdout.close)
+ self.addCleanup(p.stderr.close)
(stdout, stderr) = p.communicate()
if hasattr(file, 'newlines'):
# Interpreter with universal newline support
@@ -820,6 +831,7 @@ class Win32ProcessTestCase(BaseTestCase):
p = subprocess.Popen(["set"], shell=1,
stdout=subprocess.PIPE,
env=newenv)
+ self.addCleanup(p.stdout.close)
self.assertIn("physalis", p.stdout.read())
def test_shell_string(self):
@@ -829,6 +841,7 @@ class Win32ProcessTestCase(BaseTestCase):
p = subprocess.Popen("set", shell=1,
stdout=subprocess.PIPE,
env=newenv)
+ self.addCleanup(p.stdout.close)
self.assertIn("physalis", p.stdout.read())
def test_call_string(self):
@@ -848,6 +861,9 @@ class Win32ProcessTestCase(BaseTestCase):
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
+ self.addCleanup(p.stdout.close)
+ self.addCleanup(p.stderr.close)
+ self.addCleanup(p.stdin.close)
# Wait for the interpreter to be completely initialized before
# sending any signal.
p.stdout.read(1)
@@ -917,6 +933,7 @@ class CommandsWithSpaces (BaseTestCase):
def with_spaces(self, *args, **kwargs):
kwargs['stdout'] = subprocess.PIPE
p = subprocess.Popen(*args, **kwargs)
+ self.addCleanup(p.stdout.close)
self.assertEqual(
p.stdout.read ().decode("mbcs"),
"2 [%r, 'ab cd']" % self.fname