Skip to content

Commit

Permalink
pythongh-121988: Fix test hang when pyrepl is not available (python#1…
Browse files Browse the repository at this point in the history
…21990)

Also explicitly fail the test if we timeout while waiting for output so
that this failure mode is caught earlier.
  • Loading branch information
colesbury authored Jul 20, 2024
1 parent b7ad711 commit a09e215
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Lib/test/test_pyrepl/test_pyrepl.py
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ def _run_repl_globals_test(self, expectations, *, as_file=False, as_module=False
mod.write_text("FOO = 42", encoding="utf-8")
commands = [
"print(f'{" + var + "=}')" for var in expectations
] + ["exit"]
] + ["exit()"]
if as_file and as_module:
self.fail("as_file and as_module are mutually exclusive")
elif as_file:
Expand Down Expand Up @@ -1115,6 +1115,10 @@ def run_repl(
except OSError:
break
output.append(data)
else:
os.close(master_fd)
process.kill()
self.fail(f"Timeout while waiting for output, got: {''.join(output)}")

os.close(master_fd)
try:
Expand Down

0 comments on commit a09e215

Please sign in to comment.