summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_subprocess.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-03-08 07:17:28 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-03-08 07:17:28 (GMT)
commitcfb5b87860a6c605c89ec9d409852641ae47f654 (patch)
tree1b3d3ab85c41b015ff164e5d3b9ff10de55499d0 /Lib/test/test_subprocess.py
parentd5a0be6fc065186c93b781ba6d6308bf1414fb0d (diff)
parentf87afb0381e968f72de5a2e2bd230d4360896205 (diff)
downloadcpython-cfb5b87860a6c605c89ec9d409852641ae47f654.zip
cpython-cfb5b87860a6c605c89ec9d409852641ae47f654.tar.gz
cpython-cfb5b87860a6c605c89ec9d409852641ae47f654.tar.bz2
Issue #21619: Cleaned up test_broken_pipe_cleanup.
Patch by Martin Panter.
Diffstat (limited to 'Lib/test/test_subprocess.py')
-rw-r--r--Lib/test/test_subprocess.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index cbdbb17..e25cccd 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -2504,21 +2504,19 @@ class ContextManagerTests(BaseTestCase):
def test_broken_pipe_cleanup(self):
"""Broken pipe error should not prevent wait() (Issue 21619)"""
- args = [sys.executable, "-c",
- "import sys;"
- "sys.stdin.close();"
- "sys.stdout.close();"] # Signals that input pipe is closed
- proc = subprocess.Popen(args,
+ proc = subprocess.Popen([sys.executable, '-c', 'pass'],
stdin=subprocess.PIPE,
- stdout=subprocess.PIPE,
bufsize=support.PIPE_MAX_SIZE*2)
- proc.stdout.read() # Make sure subprocess has closed its input
- proc.stdin.write(b"x" * support.PIPE_MAX_SIZE)
+ proc = proc.__enter__()
+ # Prepare to send enough data to overflow any OS pipe buffering and
+ # guarantee a broken pipe error. Data is held in BufferedWriter
+ # buffer until closed.
+ proc.stdin.write(b'x' * support.PIPE_MAX_SIZE)
self.assertIsNone(proc.returncode)
+ # EPIPE expected under POSIX; EINVAL under Windows
self.assertRaises(OSError, proc.__exit__, None, None, None)
- self.assertEqual(0, proc.returncode)
+ self.assertEqual(proc.returncode, 0)
self.assertTrue(proc.stdin.closed)
- self.assertTrue(proc.stdout.closed)
def test_main():