Skip to content

Commit 970f805

Browse files
asvetlovclaude
andcommitted
Make test_unhandled_exception and test_unhandled_cancel wait for the handler
The client could close and the test close the server before the server accepted the connection, so the handler never ran. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 647da7e commit 970f805

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎Lib/test/test_asyncio/test_streams.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,8 +1294,12 @@ def _basetest_unhandled_exceptions(self, handle_echo):
12941294

12951295
async def client(addr):
12961296
rd, wr = await asyncio.open_connection(*addr)
1297-
wr.write(b'test msg')
1298-
await wr.drain()
1297+
# Wait until the server's handler has run and closed the
1298+
# connection: closing the server before it accepts the
1299+
# connection would drop it.
1300+
async with asyncio.timeout(60):
1301+
data = await rd.read()
1302+
self.assertEqual(data, b'')
12991303
wr.close()
13001304
await wr.wait_closed()
13011305

0 commit comments

Comments
 (0)