diff options
author | Ćukasz Langa <lukasz@langa.pl> | 2024-07-17 18:05:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-17 16:05:34 +0000 |
commit | 19cbf8fd636192059550d0c908c3e29797feed1f (patch) | |
tree | c3b9334c9a7e046de901dacf7b20d1ede8bdc5f0 /Lib/test/test_pyrepl/test_pyrepl.py | |
parent | ac07451116d52dd6a5545d27b6a2e3737ed27cf0 (diff) | |
download | cpython-19cbf8fd636192059550d0c908c3e29797feed1f.tar.gz cpython-19cbf8fd636192059550d0c908c3e29797feed1f.zip |
gh-120678: Guard against stdin.fileno() being unavailable (#121924)
Diffstat (limited to 'Lib/test/test_pyrepl/test_pyrepl.py')
-rw-r--r-- | Lib/test/test_pyrepl/test_pyrepl.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/Lib/test/test_pyrepl/test_pyrepl.py b/Lib/test/test_pyrepl/test_pyrepl.py index 6451d6104b5..e6fcb69571c 100644 --- a/Lib/test/test_pyrepl/test_pyrepl.py +++ b/Lib/test/test_pyrepl/test_pyrepl.py @@ -491,15 +491,23 @@ class TestPyReplOutput(TestCase): def test_stdin_is_tty(self): # Used during test log analysis to figure out if a TTY was available. - if os.isatty(sys.stdin.fileno()): - return - self.skipTest("stdin is not a tty") + try: + if os.isatty(sys.stdin.fileno()): + return + except OSError as ose: + self.skipTest(f"stdin tty check failed: {ose}") + else: + self.skipTest("stdin is not a tty") def test_stdout_is_tty(self): # Used during test log analysis to figure out if a TTY was available. - if os.isatty(sys.stdout.fileno()): - return - self.skipTest("stdout is not a tty") + try: + if os.isatty(sys.stdout.fileno()): + return + except OSError as ose: + self.skipTest(f"stdout tty check failed: {ose}") + else: + self.skipTest("stdout is not a tty") def test_basic(self): reader = self.prepare_reader(code_to_events("1+1\n")) |