Skip to content
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

cli: Fix TTY test failing on Python 3.14 #709

Merged
merged 2 commits into from
Jan 14, 2025
Merged
Changes from all commits
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
7 changes: 2 additions & 5 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import fcntl
import locale
import os
import pty
Expand Down Expand Up @@ -500,7 +499,7 @@ def test_run_default_format_output_in_tty(self):

# Create a pseudo-TTY and redirect stdout to it
master, slave = pty.openpty()
sys.stdout = sys.stderr = os.fdopen(slave, 'w')
sys.stdout = os.fdopen(slave, 'w')

with self.assertRaises(SystemExit) as ctx:
cli.run((path, ))
Expand All @@ -510,13 +509,11 @@ def test_run_default_format_output_in_tty(self):

# Read output from TTY
output = os.fdopen(master, 'r')
flag = fcntl.fcntl(master, fcntl.F_GETFD)
fcntl.fcntl(master, fcntl.F_SETFL, flag | os.O_NONBLOCK)
os.set_blocking(master, False)

out = output.read().replace('\r\n', '\n')

sys.stdout.close()
sys.stderr.close()
output.close()

self.assertEqual(out, (
Expand Down
Loading