[3.13] gh-121988: Fix test hang when pyrepl is not available (GH-121990) (#122064)

gh-121988: Fix test hang when pyrepl is not available (GH-121990)

Also explicitly fail the test if we timeout while waiting for output so
that this failure mode is caught earlier.
(cherry picked from commit a09e215abf)

Co-authored-by: Sam Gross <colesbury@gmail.com>
This commit is contained in:
Miss Islington (bot) 2024-07-20 16:32:41 +02:00 committed by GitHub
parent efc7d1ca86
commit bd5121b1c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 1 deletions

View File

@ -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: