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.
This commit is contained in:
Serhiy Storchaka 2025-04-24 19:07:00 +03:00 committed by GitHub
parent bab59a904c
commit 8c975b0fdd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -9,11 +9,6 @@
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 @@ def test_ioctl_mutate_2048(self):
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)