summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_subprocess.py
diff options
context:
space:
mode:
authorAndrew Svetlov <andrew.svetlov@gmail.com>2012-08-14 15:40:21 (GMT)
committerAndrew Svetlov <andrew.svetlov@gmail.com>2012-08-14 15:40:21 (GMT)
commitaa0dbdc2ddb4cfe1669ac83a24673a8ef4ee1fc4 (patch)
tree23dbc642b8059bdbc8be3be03b42476be77aa7dd /Lib/test/test_subprocess.py
parentf06afe35b9eca02cc99e77c19512841f2d889aef (diff)
parentf3765071eb73ffb3630a64987f7dceddf64be2ea (diff)
downloadcpython-aa0dbdc2ddb4cfe1669ac83a24673a8ef4ee1fc4.zip
cpython-aa0dbdc2ddb4cfe1669ac83a24673a8ef4ee1fc4.tar.gz
cpython-aa0dbdc2ddb4cfe1669ac83a24673a8ef4ee1fc4.tar.bz2
Issue #15592. Fix regression: subprocess.communicate() breaks on no input with universal newlines true.
Patch by Chris Jerdonek.
Diffstat (limited to 'Lib/test/test_subprocess.py')
-rw-r--r--Lib/test/test_subprocess.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 552b13e..e591d2f 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -615,8 +615,6 @@ class ProcessTestCase(BaseTestCase):
universal_newlines=1)
self.addCleanup(p.stdout.close)
self.addCleanup(p.stderr.close)
- # BUG: can't give a non-empty stdin because it breaks both the
- # select- and poll-based communicate() implementations.
(stdout, stderr) = p.communicate()
self.assertEqual(stdout,
"line2\nline4\nline5\nline6\nline7\nline8")
@@ -635,6 +633,18 @@ class ProcessTestCase(BaseTestCase):
(stdout, stderr) = p.communicate("line1\nline3\n")
self.assertEqual(p.returncode, 0)
+ def test_universal_newlines_communicate_input_none(self):
+ # Test communicate(input=None) with universal newlines.
+ #
+ # We set stdout to PIPE because, as of this writing, a different
+ # code path is tested when the number of pipes is zero or one.
+ p = subprocess.Popen([sys.executable, "-c", "pass"],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ universal_newlines=True)
+ p.communicate()
+ self.assertEqual(p.returncode, 0)
+
def test_no_leaking(self):
# Make sure we leak no resources
if not mswindows: