8000 gh-85984: Utilize new "winsize" functions from termios in pty tests. by 8vasu · Pull Request #101831 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-85984: Utilize new "winsize" functions from termios in pty tests. #101831

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 12, 2023
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
Remove import_module("fcntl") and test__copy_eof_on_all().
Signed-off-by: Soumendra Ganguly <soumendraganguly@gmail.com>
  • Loading branch information
8vasu committed Feb 12, 2023
commit cd0742c9df207dc1d55d199bea23a7d75be49adc
33 changes: 5 additions & 28 deletions Lib/test/test_pty.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from test.support import verbose, reap_children
from test.support.import_helper import import_module

# Skip these tests if termios or fcntl are not available
# Skip these tests if termios is not available
import_module('termios')
import_module("fcntl")

import errno
import os
Expand Down Expand Up @@ -94,7 +93,7 @@ def setUp(self):
if _HAVE_WINSZ:
try:
self.stdin_dim = tty.tcgetwinsize(pty.STDIN_FILENO)
self.addCleanup(tty.tcsetwinsize, pty.STDIN_FILENO, \
self.addCleanup(tty.tcsetwinsize, pty.STDIN_FILENO,
self.stdin_dim)
except tty.error:
pass
Expand All @@ -116,7 +115,7 @@ def test_openpty(self):
mode = None

new_dim = None
if self.stdin_dim != None:
if self.stdin_dim:
try:
# Modify pty.STDIN_FILENO window size; we need to
# check if pty.openpty() is able to set pty slave
Expand All @@ -139,12 +138,12 @@ def test_openpty(self):
try:
debug("Calling pty.openpty()")
try:
master_fd, slave_fd, slave_name = pty.openpty(mode, new_dim, \
master_fd, slave_fd, slave_name = pty.openpty(mode, new_dim,
True)
except TypeError:
master_fd, slave_fd = pty.openpty()
slave_name = None
debug(f"Got master_fd '{master_fd}', slave_fd '{slave_fd}', slave_name '{slave_name}'")
debug(f"Got {master_fd=}, {slave_fd=}, {slave_name=}")
except OSError:
# " An optional feature could not be imported " ... ?
raise unittest.SkipTest("Pseudo-terminals (seemingly) not functional.")
Expand Down Expand Up @@ -387,28 +386,6 @@ def test__copy_to_each(self):
self.assertEqual(os.read(read_from_stdout_fd, 20), b'from master')
self.assertEqual(os.read(masters[1], 20), b'from stdin')

# def test__copy_eof_on_all(self):
# """Test the empty read EOF case on both master_fd and stdin."""
# read_from_stdout_fd, mock_stdout_fd = self._pipe()
# pty.STDOUT_FILENO = mock_stdout_fd
# mock_stdin_fd, write_to_stdin_fd = self._pipe()
# pty.STDIN_FILENO = mock_stdin_fd
# socketpair = self._socketpair()
# masters = [s.fileno() for s in socketpair]

# socketpair[1].close()
# os.close(write_to_stdin_fd)

# pty.select = self._mock_select
# self.select_rfds_lengths.append(2)
# self.select_rfds_results.append([mock_stdin_fd, masters[0]])
# # We expect that both fds were removed from the fds list as they
# # both encountered an EOF before the second select call.
# self.select_rfds_lengths.append(0)

# # We expect the function to return without error.
# self.assertEqual(pty._copy(masters[0]), None)

def test__restore_tty_mode_normal_return(self):
"""Test that spawn resets the tty mode no when _copy returns normally."""

Expand Down
0