]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Use os.openpty() instead of pty.openpty() in test_ioctl (GH-132880)
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 24 Apr 2025 16:07:00 +0000 (19:07 +0300)
committerGitHub <noreply@github.com>
Thu, 24 Apr 2025 16:07:00 +0000 (16:07 +0000)
pty.openpty() does not work on Android, and it is easier to check
availability of os.openpty.

Lib/test/test_ioctl.py

index da5b576be51e9b941125582b3468560541b3acb6..b291333b00010bcba3cb0a0fc2051fae24dfde96 100644 (file)
@@ -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)