Skip to content

Commit c35c599

Browse files
tweak test
1 parent 48df4e8 commit c35c599

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

Lib/test/test_asyncio/test_sslproto.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,20 @@ def test_connection_lost_when_busy(self):
142142
transport = ssl_proto._app_transport
143143
writer = asyncio.StreamWriter(transport, protocol, reader, self.loop)
144144

145-
# Write data to the transport n times in a task that blocks the
146-
# asyncio event loop from a user perspective.
147-
async def _write_loop(n):
148-
for i in range(n):
145+
async def main():
146+
# writes data to transport
147+
async def write():
149148
writer.write(data)
150149
await writer.drain()
151150

152-
# The test is successful if we raise the error the next time
153-
# we try to write to the transport.
154-
with self.assertRaises(ConnectionResetError):
155-
self.loop.run_until_complete(_write_loop(2))
151+
# try to write for the first time
152+
await write()
153+
# try to write for the second time, this raises as the connection_lost
154+
# callback should be done with error
155+
with self.assertRaises(ConnectionResetError):
156+
await write()
157+
158+
self.loop.run_until_complete(main())
156159

157160
def test_close_during_handshake(self):
158161
# bpo-29743 Closing transport during handshake process leaks socket

0 commit comments

Comments
 (0)