diff options
author | Andrew Svetlov <andrew.svetlov@gmail.com> | 2012-08-19 13:25:37 (GMT) |
---|---|---|
committer | Andrew Svetlov <andrew.svetlov@gmail.com> | 2012-08-19 13:25:37 (GMT) |
commit | 47ec25d2f6d1b3aeb148bf6f88fee1c0b51dccdb (patch) | |
tree | 19e1774ae286a0b535ee1302aa46c58a4eb64dce /Lib/test/test_subprocess.py | |
parent | 4d16bcce07cbd681edbb7fcf944c39f71bb43cfd (diff) | |
download | cpython-47ec25d2f6d1b3aeb148bf6f88fee1c0b51dccdb.zip cpython-47ec25d2f6d1b3aeb148bf6f88fee1c0b51dccdb.tar.gz cpython-47ec25d2f6d1b3aeb148bf6f88fee1c0b51dccdb.tar.bz2 |
Brush subprocess tests a bit.
Diffstat (limited to 'Lib/test/test_subprocess.py')
-rw-r--r-- | Lib/test/test_subprocess.py | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index 6ec72c7..74ce091 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -14,6 +14,7 @@ import warnings import select import shutil import gc +import textwrap try: import resource @@ -622,12 +623,12 @@ class ProcessTestCase(BaseTestCase): def test_universal_newlines_communicate_stdin(self): # universal newlines through communicate(), with only stdin p = subprocess.Popen([sys.executable, "-c", - 'import sys,os;' + SETBINARY + '''\nif True: - s = sys.stdin.readline() - assert s == "line1\\n", repr(s) - s = sys.stdin.read() - assert s == "line3\\n", repr(s) - '''], + 'import sys,os;' + SETBINARY + textwrap.dedent(''' + s = sys.stdin.readline() + assert s == "line1\\n", repr(s) + s = sys.stdin.read() + assert s == "line3\\n", repr(s) + ''')], stdin=subprocess.PIPE, universal_newlines=1) (stdout, stderr) = p.communicate("line1\nline3\n") @@ -646,24 +647,24 @@ class ProcessTestCase(BaseTestCase): self.assertEqual(p.returncode, 0) def test_universal_newlines_communicate_stdin_stdout_stderr(self): - # universal newlines through communicate(), with only stdin + # universal newlines through communicate(), with stdin, stdout, stderr p = subprocess.Popen([sys.executable, "-c", - 'import sys,os;' + SETBINARY + '''\nif True: - s = sys.stdin.readline() - sys.stdout.buffer.write(s.encode()) - sys.stdout.buffer.write(b"line2\\r") - sys.stderr.buffer.write(b"eline2\\n") - s = sys.stdin.read() - sys.stdout.buffer.write(s.encode()) - sys.stdout.buffer.write(b"line4\\n") - sys.stdout.buffer.write(b"line5\\r\\n") - sys.stderr.buffer.write(b"eline6\\r") - sys.stderr.buffer.write(b"eline7\\r\\nz") - '''], + 'import sys,os;' + SETBINARY + textwrap.dedent(''' + s = sys.stdin.buffer.readline() + sys.stdout.buffer.write(s) + sys.stdout.buffer.write(b"line2\\r") + sys.stderr.buffer.write(b"eline2\\n") + s = sys.stdin.buffer.read() + sys.stdout.buffer.write(s) + sys.stdout.buffer.write(b"line4\\n") + sys.stdout.buffer.write(b"line5\\r\\n") + sys.stderr.buffer.write(b"eline6\\r") + sys.stderr.buffer.write(b"eline7\\r\\nz") + ''')], stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE, - universal_newlines=1) + universal_newlines=True) self.addCleanup(p.stdout.close) self.addCleanup(p.stderr.close) (stdout, stderr) = p.communicate("line1\nline3\n") |