Skip to content

Commit 1779aa3

Browse files
8vasuadorilson
authored andcommitted
bpo-41818: Fix test_master_read() so that it succeeds on all platforms that either raise OSError or return b"" upon reading from master (pythonGH-23536)
Signed-off-by: Soumendra Ganguly <soumendraganguly@gmail.com>
1 parent c485fbe commit 1779aa3

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

Lib/test/test_pty.py

+5-10
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import struct
1818
import tty
1919
import fcntl
20-
import platform
2120
import warnings
2221

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

85-
def expectedFailureOnBSD(fun):
86-
PLATFORM = platform.system()
87-
if PLATFORM.endswith("BSD") or PLATFORM == "Darwin":
88-
return unittest.expectedFailure(fun)
89-
return fun
90-
9184
def _get_term_winsz(fd):
9285
s = struct.pack("HHHH", 0, 0, 0, 0)
9386
return fcntl.ioctl(fd, _TIOCGWINSZ, s)
@@ -314,7 +307,6 @@ def test_fork(self):
314307

315308
os.close(master_fd)
316309

317-
@expectedFailureOnBSD
318310
def test_master_read(self):
319311
debug("Calling pty.openpty()")
320312
master_fd, slave_fd = pty.openpty()
@@ -324,10 +316,13 @@ def test_master_read(self):
324316
os.close(slave_fd)
325317

326318
debug("Reading from master_fd")
327-
with self.assertRaises(OSError):
328-
os.read(master_fd, 1)
319+
try:
320+
data = os.read(master_fd, 1)
321+
except OSError: # Linux
322+
data = b""
329323

330324
os.close(master_fd)
325+
self.assertEqual(data, b"")
331326

332327
class SmallPtyTests(unittest.TestCase):
333328
"""These tests don't spawn children or hang."""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix test_master_read() so that it succeeds on all platforms that either raise OSError or return b"" upon reading from master.

0 commit comments

Comments
 (0)