diff options
author | Soumendra Ganguly <67527439+8vasu@users.noreply.github.com> | 2020-11-28 15:04:20 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-28 23:04:20 +0200 |
commit | 74311aeb45b52cc145d27d9fca99f01874d6882d (patch) | |
tree | 6269773b09698f393af9747331321e9f6166109a | |
parent | aa1b8a168d8b8dc1dfc426364b7b664501302958 (diff) | |
download | cpython-git-74311aeb45b52cc145d27d9fca99f01874d6882d.tar.gz |
bpo-41818: Fix test_master_read() so that it succeeds on all platforms that either raise OSError or return b"" upon reading from master (GH-23536)
Signed-off-by: Soumendra Ganguly <soumendraganguly@gmail.com>
-rw-r--r-- | Lib/test/test_pty.py | 15 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2020-11-28-06-34-53.bpo-41818.mFSMc2.rst | 1 |
2 files changed, 6 insertions, 10 deletions
diff --git a/Lib/test/test_pty.py b/Lib/test/test_pty.py index a45be284a9..190d8d787a 100644 --- a/Lib/test/test_pty.py +++ b/Lib/test/test_pty.py @@ -17,7 +17,6 @@ import unittest import struct import tty import fcntl -import platform import warnings TEST_STRING_1 = b"I wish to buy a fish license.\n" @@ -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) @@ -314,7 +307,6 @@ class PtyTest(unittest.TestCase): os.close(master_fd) - @expectedFailureOnBSD def test_master_read(self): debug("Calling pty.openpty()") master_fd, slave_fd = pty.openpty() @@ -324,10 +316,13 @@ class PtyTest(unittest.TestCase): 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.""" diff --git a/Misc/NEWS.d/next/Library/2020-11-28-06-34-53.bpo-41818.mFSMc2.rst b/Misc/NEWS.d/next/Library/2020-11-28-06-34-53.bpo-41818.mFSMc2.rst new file mode 100644 index 0000000000..b783f8cec1 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-11-28-06-34-53.bpo-41818.mFSMc2.rst @@ -0,0 +1 @@ +Fix test_master_read() so that it succeeds on all platforms that either raise OSError or return b"" upon reading from master.
\ No newline at end of file |