diff --git a/test/pytest/test_peer.py b/test/pytest/test_peer.py index 78e9a7028700..cba57540e5c7 100644 --- a/test/pytest/test_peer.py +++ b/test/pytest/test_peer.py @@ -187,8 +187,10 @@ def __init__(self, *, specific_error=False): self.specific_error = specific_error async def do_connect_transport(self) -> None: - transport = await self.spawn(['sh', '-c', 'exit 9'], ()) + transport = await self.spawn(['sh', '-c', 'read a; exit 9'], ()) assert isinstance(transport, SubprocessTransport) + # Make the process exit by writing a newline (causing `read` to finish) + transport.write(b'\n') # The process will exit soon — try writing to it until a write fails. while not transport.is_closing(): transport.write(b'x')