Skip to content

Commit

Permalink
pythongh-120678: Guard against stdin.fileno() being unavailable
Browse files Browse the repository at this point in the history
  • Loading branch information
ambv authored Jul 17, 2024
1 parent ac07451 commit 00573a4
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions Lib/test/test_pyrepl/test_pyrepl.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,15 +491,23 @@ def prepare_reader(self, events):

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"))
Expand Down

0 comments on commit 00573a4

Please sign in to comment.