Kaydet (Commit) 20f4bd4a authored tarafından Victor Stinner's avatar Victor Stinner

Issue #21619: Try to fix test_broken_pipe_cleanup()

üst f7f3b0a1
...@@ -2523,13 +2523,16 @@ class ContextManagerTests(BaseTestCase): ...@@ -2523,13 +2523,16 @@ class ContextManagerTests(BaseTestCase):
def test_broken_pipe_cleanup(self): def test_broken_pipe_cleanup(self):
"""Broken pipe error should not prevent wait() (Issue 21619)""" """Broken pipe error should not prevent wait() (Issue 21619)"""
proc = subprocess.Popen([sys.executable, "-c", args = [sys.executable, "-c",
"import sys;" "import sys;"
"sys.stdin.close();" "sys.stdin.close();"
"sys.stdout.close();" # Signals that input pipe is closed "sys.stdout.close();"] # Signals that input pipe is closed
], stdin=subprocess.PIPE, stdout=subprocess.PIPE) proc = subprocess.Popen(args,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
bufsize=support.PIPE_MAX_SIZE*2)
proc.stdout.read() # Make sure subprocess has closed its input proc.stdout.read() # Make sure subprocess has closed its input
proc.stdin.write(b"buffered data") proc.stdin.write(b"x" * support.PIPE_MAX_SIZE)
self.assertIsNone(proc.returncode) self.assertIsNone(proc.returncode)
self.assertRaises(OSError, proc.__exit__, None, None, None) self.assertRaises(OSError, proc.__exit__, None, None, None)
self.assertEqual(0, proc.returncode) self.assertEqual(0, proc.returncode)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment