aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_pyrepl/test_pyrepl.py
diff options
context:
space:
mode:
authorSam Gross <colesbury@gmail.com>2024-07-20 10:04:14 -0400
committerGitHub <noreply@github.com>2024-07-20 16:04:14 +0200
commita09e215abf3c80a3c99c86b4482b512b42aad072 (patch)
treeb0a121e25cefab953667187676815420ba1396b5 /Lib/test/test_pyrepl/test_pyrepl.py
parentb7ad711fcb37dd001e6bf8466c9503eef6d20331 (diff)
downloadcpython-a09e215abf3c80a3c99c86b4482b512b42aad072.tar.gz
cpython-a09e215abf3c80a3c99c86b4482b512b42aad072.zip
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.
Diffstat (limited to 'Lib/test/test_pyrepl/test_pyrepl.py')
-rw-r--r--Lib/test/test_pyrepl/test_pyrepl.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/test/test_pyrepl/test_pyrepl.py b/Lib/test/test_pyrepl/test_pyrepl.py
index e6fcb69571c..e3feeeb76f1 100644
--- a/Lib/test/test_pyrepl/test_pyrepl.py
+++ b/Lib/test/test_pyrepl/test_pyrepl.py
@@ -964,7 +964,7 @@ class TestMain(TestCase):
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:
@@ -1115,6 +1115,10 @@ class TestMain(TestCase):
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: