Skip to content

Commit c8ec7e6

Browse files
add test for proactor event loop
1 parent 365852a commit c8ec7e6

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Lib/test/test_asyncio/test_proactor_events.py

+23
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,29 @@ def test_force_close_idempotent(self):
297297
# and waiters will never be notified leading to hang.
298298
self.assertTrue(self.protocol.connection_lost.called)
299299

300+
def test_force_close_protocol_connection_lost_once(self):
301+
tr = self.socket_transport()
302+
self.assertFalse(self.protocol.connection_lost.called)
303+
tr._closing = True
304+
# Calling _force_close twice should not call
305+
# protocol.connection_lost twice
306+
tr._force_close(None)
307+
tr._force_close(None)
308+
test_utils.run_briefly(self.loop)
309+
self.assertEqual(1, self.protocol.connection_lost.call_count)
310+
self.assertEqual(1, self._sock.close.call_count)
311+
312+
def test_close_protocol_connection_lost_once(self):
313+
tr = self.socket_transport()
314+
self.assertFalse(self.protocol.connection_lost.called)
315+
# Calling close twice should not call
316+
# protocol.connection_lost twice
317+
tr.close()
318+
tr.close()
319+
test_utils.run_briefly(self.loop)
320+
self.assertEqual(1, self.protocol.connection_lost.call_count)
321+
self.assertEqual(1, self._sock.close.call_count)
322+
300323
def test_fatal_error_2(self):
301324
tr = self.socket_transport()
302325
tr._buffer = [b'data']

0 commit comments

Comments
 (0)