[Python-checkins] cpython (merge 3.4 -> default): Issue #21619: Cleaned up test_broken_pipe_cleanup.
serhiy.storchaka
python-checkins at python.org
Sun Mar 8 08:18:37 CET 2015
https://hg.python.org/cpython/rev/41ce95a5b2d8
changeset: 94903:41ce95a5b2d8
parent: 94901:3e12444adf1e
parent: 94902:4ea40dc3d26d
user: Serhiy Storchaka <storchaka at gmail.com>
date: Sun Mar 08 09:17:28 2015 +0200
summary:
Issue #21619: Cleaned up test_broken_pipe_cleanup.
Patch by Martin Panter.
files:
Lib/test/test_subprocess.py | 18 ++++++++----------
1 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -2504,21 +2504,19 @@
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():
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list