Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
bpo-31158: Fix test_pty.test_basic()
Sometimes, the first read only returns the first written 5 bytes and
a second read is need to get the second part.
  • Loading branch information
vstinner committed Sep 28, 2017
commit cef1e369454845b14c65a1712b65a4708cf62c1a
11 changes: 10 additions & 1 deletion Lib/test/test_pty.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,17 @@ def test_basic(self):
debug("Writing chunked output")
os.write(slave_fd, TEST_STRING_2[:5])
os.write(slave_fd, TEST_STRING_2[5:])

expected = b'For my pet fish, Eric.\n'
s2 = os.read(master_fd, 1024)
self.assertEqual(b'For my pet fish, Eric.\n', normalize_output(s2))
# bpo-31158: Sometimes, the first read only returns the first
# written 5 bytes and a second read is need to get the second part.
while len(s2) < len(expected):
chunk = os.read(master_fd, 1024)
if not chunk:
break
s2 += chunk
self.assertEqual(expected, normalize_output(s2))

os.close(slave_fd)
os.close(master_fd)
Expand Down