Commit c979a25c authored by Jason Madden's avatar Jason Madden

Fix test__subprocess for Py3. A premature close of half the pipe was causing...

Fix test__subprocess for Py3. A premature close of half the pipe was causing the whole pipe to get closed, apparently, at least under OS X, so don't close it. The test still fails if the fix is removed.

I'm not 100% sure this is the correct fix; could there be some underlying issue? The subprocess code is the same on both Py2 and Py3.
parent 4246a432
......@@ -619,7 +619,7 @@ class _fileobject(object):
continue
break
return "".join(buffers)
return b"".join(buffers)
buf.seek(0, 2) # seek end
self._rbuf = BytesIO() # reset _rbuf. we consume it via buf.
......
......@@ -92,7 +92,7 @@ class Test(greentest.TestCase):
if python_universal_newlines:
# Interpreter with universal newline support
self.assertEqual(stdout,
"line1\nline2\nline3\nline4\nline5\nline6")
b"line1\nline2\nline3\nline4\nline5\nline6")
else:
# Interpreter without universal newline support
self.assertEqual(stdout,
......@@ -119,7 +119,7 @@ class Test(greentest.TestCase):
if python_universal_newlines:
# Interpreter with universal newline support
self.assertEqual(stdout,
"line1\nline2\nline3\nline4\nline5\nline6")
b"line1\nline2\nline3\nline4\nline5\nline6")
else:
# Interpreter without universal newline support
self.assertEqual(stdout,
......@@ -134,7 +134,12 @@ class Test(greentest.TestCase):
r, w = os.pipe()
p = subprocess.Popen(['grep', 'text'], stdin=subprocess.FileObject(r))
try:
os.close(w)
# Closing one half of the pipe causes Python 3 on OS X to terminate the
# child process; it exits with code 1 and the assert that p.poll is None
# fails. Removing the close lets it pass under both Python 3 and 2.7.
# If subprocess.Popen._remove_nonblock_flag is changed to a noop, then
# the test fails (as expected) even with the close removed
#os.close(w)
time.sleep(0.1)
self.assertEqual(p.poll(), None)
finally:
......@@ -165,9 +170,9 @@ class Test(greentest.TestCase):
p = subprocess.Popen([sys.executable, '-u', '-c',
'import sys; sys.stdout.write(sys.stdin.readline())'],
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
p.stdin.write('foobar\n')
p.stdin.write(b'foobar\n')
r = p.stdout.readline()
self.assertEqual(r, 'foobar\n')
self.assertEqual(r, b'foobar\n')
if __name__ == '__main__':
......
......@@ -86,7 +86,6 @@ if PY3:
test__example_udp_server.py
test_threading_2.py
test__refcount.py
test__subprocess.py
test__all__.py
test__pywsgi.py
test__example_echoserver.py
......
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