|
5 | 5 | import_module('termios')
|
6 | 6 |
|
7 | 7 | import errno
|
8 |
| -import pathlib |
9 | 8 | import pty
|
10 | 9 | import os
|
11 | 10 | import sys
|
@@ -75,20 +74,7 @@ def _readline(fd):
|
75 | 74 | return reader.readline()
|
76 | 75 |
|
77 | 76 | def expectedFailureIfStdinIsTTY(fun):
|
78 |
| - # avoid isatty() for now |
79 |
| - PLATFORM = platform.system() |
80 |
| - if PLATFORM == "Linux": |
81 |
| - os_release = pathlib.Path("/etc/os-release") |
82 |
| - if os_release.exists(): |
83 |
| - # Actually the file has complex multi-line structure, |
84 |
| - # these is no need to parse it for Gentoo check |
85 |
| - if 'gentoo' in os_release.read_text().lower(): |
86 |
| - # bpo-41818: |
87 |
| - # Gentoo passes the test, |
88 |
| - # all other tested Linux distributions fail. |
89 |
| - # Should not apply @unittest.expectedFailure() on Gentoo |
90 |
| - # to keep the buildbot fleet happy. |
91 |
| - return fun |
| 77 | + # avoid isatty() |
92 | 78 | try:
|
93 | 79 | tty.tcgetattr(pty.STDIN_FILENO)
|
94 | 80 | return unittest.expectedFailure(fun)
|
@@ -165,11 +151,16 @@ def test_openpty(self):
|
165 | 151 | new_stdin_winsz = None
|
166 | 152 | if self.stdin_rows != None and self.stdin_cols != None:
|
167 | 153 | try:
|
| 154 | + # Modify pty.STDIN_FILENO window size; we need to |
| 155 | + # check if pty.openpty() is able to set pty slave |
| 156 | + # window size accordingly. |
168 | 157 | debug("Setting pty.STDIN_FILENO window size")
|
169 |
| - # Set number of columns and rows to be the |
170 |
| - # floors of 1/5 of respective original values |
171 |
| - target_stdin_winsz = struct.pack("HHHH", self.stdin_rows//5, |
172 |
| - self.stdin_cols//5, 0, 0) |
| 158 | + debug(f"original size: (rows={self.stdin_rows}, cols={self.stdin_cols})") |
| 159 | + target_stdin_rows = self.stdin_rows + 1 |
| 160 | + target_stdin_cols = self.stdin_cols + 1 |
| 161 | + debug(f"target size: (rows={target_stdin_rows}, cols={target_stdin_cols})") |
| 162 | + target_stdin_winsz = struct.pack("HHHH", target_stdin_rows, |
| 163 | + target_stdin_cols, 0, 0) |
173 | 164 | _set_term_winsz(pty.STDIN_FILENO, target_stdin_winsz)
|
174 | 165 |
|
175 | 166 | # Were we able to set the window size
|
|
0 commit comments