Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use pseudo-terminal.
  • Loading branch information
serhiy-storchaka committed Oct 6, 2023
commit 99858f0e307895da17386187df6dd8610a6df7a5
11 changes: 5 additions & 6 deletions Lib/test/test_tty.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import io
import os
import unittest
from test.support.import_helper import import_module

termios = import_module('termios')
tty = import_module('tty')


@unittest.skipUnless(hasattr(os, 'openpty'), "need os.openpty()")
class TestTty(unittest.TestCase):

def setUp(self):
try:
self.stream = open('/dev/tty', 'wb', buffering=0)
except OSError:
self.skipTest("Cannot open '/dev/tty'")
self.addCleanup(self.stream.close)
master_fd, self.fd = os.openpty()
self.addCleanup(os.close, master_fd)
self.stream = self.enterContext(open(self.fd, 'wb', buffering=0))
self.fd = self.stream.fileno()
self.mode = termios.tcgetattr(self.fd)
self.addCleanup(termios.tcsetattr, self.fd, termios.TCSANOW, self.mode)
Expand Down