From: Serhiy Storchaka Date: Thu, 24 Apr 2025 16:07:00 +0000 (+0300) Subject: Use os.openpty() instead of pty.openpty() in test_ioctl (GH-132880) X-Git-Tag: v3.14.0b1~323 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8c975b0fddf0df4172634894f61a7d7c8db48255;p=thirdparty%2FPython%2Fcpython.git Use os.openpty() instead of pty.openpty() in test_ioctl (GH-132880) pty.openpty() does not work on Android, and it is easier to check availability of os.openpty. --- diff --git a/Lib/test/test_ioctl.py b/Lib/test/test_ioctl.py index da5b576be51e..b291333b0001 100644 --- a/Lib/test/test_ioctl.py +++ b/Lib/test/test_ioctl.py @@ -9,11 +9,6 @@ from test.support.import_helper import import_module fcntl = import_module('fcntl') termios = import_module('termios') -try: - import pty -except ImportError: - pty = None - class IoctlTestsTty(unittest.TestCase): @classmethod def setUpClass(cls): @@ -136,10 +131,10 @@ class IoctlTestsTty(unittest.TestCase): self.assertRaises(ValueError, self._check_ioctl_not_mutate_len, 2048) -@unittest.skipIf(pty is None, 'pty module required') +@unittest.skipUnless(hasattr(os, 'openpty'), "need os.openpty()") class IoctlTestsPty(unittest.TestCase): def setUp(self): - self.master_fd, self.slave_fd = pty.openpty() + self.master_fd, self.slave_fd = os.openpty() self.addCleanup(os.close, self.slave_fd) self.addCleanup(os.close, self.master_fd)