From a550369e3566233126583d83b9f5c8fba5e2e31f Mon Sep 17 00:00:00 2001 From: Soumendra Ganguly Date: Sat, 28 Nov 2020 00:15:19 -0600 Subject: [PATCH 1/2] 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 --- Lib/test/test_pty.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Lib/test/test_pty.py b/Lib/test/test_pty.py index a45be284a95440..190d8d787a2cc9 100644 --- a/Lib/test/test_pty.py +++ b/Lib/test/test_pty.py @@ -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" @@ -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 @@ def test_fork(self): os.close(master_fd) - @expectedFailureOnBSD def test_master_read(self): debug("Calling pty.openpty()") master_fd, slave_fd = pty.openpty() @@ -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.""" From f994d09206589fab7404022b517b3d16132b81d2 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sat, 28 Nov 2020 06:34:54 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NEWS.d/next/Library/2020-11-28-06-34-53.bpo-41818.mFSMc2.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2020-11-28-06-34-53.bpo-41818.mFSMc2.rst 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 00000000000000..b783f8cec1c941 --- /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