Skip to content

Commit e1e0d81

Browse files
committed
Add a test that create_connection survives immediate cancellation
1 parent 22b8213 commit e1e0d81

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/test_tcp.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,26 @@ async def runner():
478478

479479
self.loop.run_until_complete(runner())
480480

481+
def test_create_connection_5(self):
482+
def server(sock):
483+
data = sock.recv_all(4)
484+
self.assertEqual(data, b'AAAA')
485+
sock.send(b'OK')
486+
487+
async def client(addr):
488+
fut = asyncio.ensure_future(
489+
self.loop.create_connection(asyncio.Protocol, *addr),
490+
loop=self.loop)
491+
await asyncio.sleep(0, loop=self.loop)
492+
fut.cancel()
493+
with self.assertRaises(asyncio.CancelledError):
494+
await fut
495+
496+
with self.tcp_server(server,
497+
max_clients=1,
498+
backlog=1) as srv:
499+
self.loop.run_until_complete(client(srv.addr))
500+
481501
def test_transport_shutdown(self):
482502
CNT = 0 # number of clients that were successful
483503
TOTAL_CNT = 100 # total number of clients that test will create

0 commit comments

Comments
 (0)