Commit ec2d2693 authored by Antoine Pitrou's avatar Antoine Pitrou

Fix universal newlines test to avoid the newline translation done by sys.stdout.

parent 894375a2
...@@ -476,21 +476,22 @@ class ProcessTestCase(BaseTestCase): ...@@ -476,21 +476,22 @@ class ProcessTestCase(BaseTestCase):
def test_universal_newlines(self): def test_universal_newlines(self):
p = subprocess.Popen([sys.executable, "-c", p = subprocess.Popen([sys.executable, "-c",
'import sys,os;' + SETBINARY + 'import sys,os;' + SETBINARY +
'sys.stdout.write(sys.stdin.readline());' 'buf = sys.stdout.buffer;'
'sys.stdout.flush();' 'buf.write(sys.stdin.readline().encode());'
'sys.stdout.write("line2\\n");' 'buf.flush();'
'sys.stdout.flush();' 'buf.write(b"line2\\n");'
'sys.stdout.write(sys.stdin.read());' 'buf.flush();'
'sys.stdout.flush();' 'buf.write(sys.stdin.read().encode());'
'sys.stdout.write("line4\\n");' 'buf.flush();'
'sys.stdout.flush();' 'buf.write(b"line4\\n");'
'sys.stdout.write("line5\\r\\n");' 'buf.flush();'
'sys.stdout.flush();' 'buf.write(b"line5\\r\\n");'
'sys.stdout.write("line6\\r");' 'buf.flush();'
'sys.stdout.flush();' 'buf.write(b"line6\\r");'
'sys.stdout.write("\\nline7");' 'buf.flush();'
'sys.stdout.flush();' 'buf.write(b"\\nline7");'
'sys.stdout.write("\\nline8");'], 'buf.flush();'
'buf.write(b"\\nline8");'],
stdin=subprocess.PIPE, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
universal_newlines=1) universal_newlines=1)
...@@ -510,17 +511,18 @@ class ProcessTestCase(BaseTestCase): ...@@ -510,17 +511,18 @@ class ProcessTestCase(BaseTestCase):
# universal newlines through communicate() # universal newlines through communicate()
p = subprocess.Popen([sys.executable, "-c", p = subprocess.Popen([sys.executable, "-c",
'import sys,os;' + SETBINARY + 'import sys,os;' + SETBINARY +
'sys.stdout.write("line2\\n");' 'buf = sys.stdout.buffer;'
'sys.stdout.flush();' 'buf.write(b"line2\\n");'
'sys.stdout.write("line4\\n");' 'buf.flush();'
'sys.stdout.flush();' 'buf.write(b"line4\\n");'
'sys.stdout.write("line5\\r\\n");' 'buf.flush();'
'sys.stdout.flush();' 'buf.write(b"line5\\r\\n");'
'sys.stdout.write("line6\\r");' 'buf.flush();'
'sys.stdout.flush();' 'buf.write(b"line6\\r");'
'sys.stdout.write("\\nline7");' 'buf.flush();'
'sys.stdout.flush();' 'buf.write(b"\\nline7");'
'sys.stdout.write("\\nline8");'], 'buf.flush();'
'buf.write(b"\\nline8");'],
stderr=subprocess.PIPE, stderr=subprocess.PIPE,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
universal_newlines=1) universal_newlines=1)
......
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