Skip to content

Commit a09e215

Browse files
authored
gh-121988: Fix test hang when pyrepl is not available (#121990)
Also explicitly fail the test if we timeout while waiting for output so that this failure mode is caught earlier.
1 parent b7ad711 commit a09e215

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Lib/test/test_pyrepl/test_pyrepl.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ def _run_repl_globals_test(self, expectations, *, as_file=False, as_module=False
964964
mod.write_text("FOO = 42", encoding="utf-8")
965965
commands = [
966966
"print(f'{" + var + "=}')" for var in expectations
967-
] + ["exit"]
967+
] + ["exit()"]
968968
if as_file and as_module:
969969
self.fail("as_file and as_module are mutually exclusive")
970970
elif as_file:
@@ -1115,6 +1115,10 @@ def run_repl(
11151115
except OSError:
11161116
break
11171117
output.append(data)
1118+
else:
1119+
os.close(master_fd)
1120+
process.kill()
1121+
self.fail(f"Timeout while waiting for output, got: {''.join(output)}")
11181122

11191123
os.close(master_fd)
11201124
try:

0 commit comments

Comments
 (0)