Also explicitly fail the test if we timeout while waiting for output so
that this failure mode is caught earlier.
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:
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: