summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAndrew Svetlov <andrew.svetlov@gmail.com>2012-08-15 19:53:56 (GMT)
committerAndrew Svetlov <andrew.svetlov@gmail.com>2012-08-15 19:53:56 (GMT)
commit9351117139363f3e600c541bc88139702a055db8 (patch)
tree6452426829fe8b061ab19546deebe98094ffec0c /Lib
parenteb41c7fef89d1eefbc4be209c545c82f868f3e6e (diff)
parent5395d2f07d3d50aef07c70c26a95193c66cb7d92 (diff)
downloadcpython-9351117139363f3e600c541bc88139702a055db8.zip
cpython-9351117139363f3e600c541bc88139702a055db8.tar.gz
cpython-9351117139363f3e600c541bc88139702a055db8.tar.bz2
merge heads
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_subprocess.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index e591d2f..72079d0 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -645,6 +645,34 @@ class ProcessTestCase(BaseTestCase):
p.communicate()
self.assertEqual(p.returncode, 0)
+ def test_universal_newlines_communicate_stdin_stdout_stderr(self):
+ # universal newlines through communicate(), with only stdin
+ p = subprocess.Popen([sys.executable, "-c",
+ 'import sys,os;' + SETBINARY + '''\nif True:
+ s = sys.stdin.readline()
+ sys.stdout.write(s)
+ sys.stdout.write("line2\\r")
+ sys.stderr.write("eline2\\n")
+ s = sys.stdin.read()
+ sys.stdout.write(s+"line4\\n")
+ sys.stdout.write(s+"line5\\r\\n")
+ sys.stderr.write("eline6\\n")
+ sys.stderr.write("eline7\\r")
+ sys.stderr.write("eline8\\r\\n")
+ '''],
+ stdin=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ universal_newlines=1)
+ self.addCleanup(p.stdout.close)
+ self.addCleanup(p.stderr.close)
+ (stdout, stderr) = p.communicate("line1\nline3\n")
+ self.assertEqual(p.returncode, 0)
+ self.assertEqual("line1\nline2\nline3\nline4\nline3\nline5\n", stdout)
+ # Python debug build push something like "[42442 refs]\n"
+ # to stderr at exit of subprocess.
+ self.assertTrue(stderr.startswith("eline2\neline6\neline7\neline8\n"))
+
def test_no_leaking(self):
# Make sure we leak no resources
if not mswindows: