Skip to content
Merged
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
Fix test_master_read() so that it succeeds on all platforms that
either raise OSError or return b"" upon reading from master

Signed-off-by: Soumendra Ganguly <soumendraganguly@gmail.com>
  • Loading branch information
8vasu committed Nov 28, 2020
commit a550369e3566233126583d83b9f5c8fba5e2e31f
15 changes: 5 additions & 10 deletions Lib/test/test_pty.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import struct
import tty
import fcntl
import platform
import warnings

TEST_STRING_1 = b"I wish to buy a fish license.\n"
Expand Down Expand Up @@ -82,12 +81,6 @@ def expectedFailureIfStdinIsTTY(fun):
pass
return fun

def expectedFailureOnBSD(fun):
PLATFORM = platform.system()
if PLATFORM.endswith("BSD") or PLATFORM == "Darwin":
return unittest.expectedFailure(fun)
return fun

def _get_term_winsz(fd):
s = struct.pack("HHHH", 0, 0, 0, 0)
return fcntl.ioctl(fd, _TIOCGWINSZ, s)
Expand Down Expand Up @@ -314,7 +307,6 @@ def test_fork(self):

os.close(master_fd)

@expectedFailureOnBSD
def test_master_read(self):
debug("Calling pty.openpty()")
master_fd, slave_fd = pty.openpty()
Expand All @@ -324,10 +316,13 @@ def test_master_read(self):
os.close(slave_fd)

debug("Reading from master_fd")
with self.assertRaises(OSError):
os.read(master_fd, 1)
try:
data = os.read(master_fd, 1)
except OSError: # Linux
data = b""

os.close(master_fd)
self.assertEqual(data, b"")

class SmallPtyTests(unittest.TestCase):
"""These tests don't spawn children or hang."""
Expand Down