From 51ffb5d81c8cb18ba5564285a663706fcd252b37 Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Wed, 26 Oct 2022 16:00:46 +0000 Subject: [PATCH] add test for proactor event loop --- Lib/test/test_asyncio/test_proactor_events.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Lib/test/test_asyncio/test_proactor_events.py b/Lib/test/test_asyncio/test_proactor_events.py index 7fd8b261cd5ee1..ae30185cef776a 100644 --- a/Lib/test/test_asyncio/test_proactor_events.py +++ b/Lib/test/test_asyncio/test_proactor_events.py @@ -297,6 +297,27 @@ def test_force_close_idempotent(self): # and waiters will never be notified leading to hang. self.assertTrue(self.protocol.connection_lost.called) + def test_force_close_protocol_connection_lost_once(self): + tr = self.socket_transport() + self.assertFalse(self.protocol.connection_lost.called) + tr._closing = True + # Calling _force_close twice should not call + # protocol.connection_lost twice + tr._force_close(None) + tr._force_close(None) + test_utils.run_briefly(self.loop) + self.assertEqual(1, self.protocol.connection_lost.call_count) + + def test_close_protocol_connection_lost_once(self): + tr = self.socket_transport() + self.assertFalse(self.protocol.connection_lost.called) + # Calling close twice should not call + # protocol.connection_lost twice + tr.close() + tr.close() + test_utils.run_briefly(self.loop) + self.assertEqual(1, self.protocol.connection_lost.call_count) + def test_fatal_error_2(self): tr = self.socket_transport() tr._buffer = [b'data']