From 4e0a367e1f1b35521302fc0f3a31f810b263fa54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Verg=C3=A9?= Date: Mon, 13 Jan 2025 17:06:16 +0100 Subject: [PATCH] cli: Fix TTY test failing on Python 3.14 Since I don't have Python 3.14 on my system (yet), here are the steps I used to reproduce: sudo dnf install python3.14 python3.14 -m venv /tmp/py3.14 source /tmp/py3.14/bin/activate pip install yaml pathspec python3.14 -m unittest discover # or python3.14 -m unittest tests.test_cli.CommandLineTestCase.test_run_default_format_output_in_tty This commit fixes that by piping *only* `sys.stdout`, not `sys.stderr` too. I'm not sure why I wrote this code in 2016 (see commit a2c68fdf), but the new one makes more sense to me now. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2336947 --- tests/test_cli.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 26e4b688..308d6181 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -499,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, )) @@ -514,7 +514,6 @@ def test_run_default_format_output_in_tty(self): out = output.read().replace('\r\n', '\n') sys.stdout.close() - sys.stderr.close() output.close() self.assertEqual(out, (