summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-10-27 03:33:19 (GMT)
committerGitHub <noreply@github.com>2022-10-27 03:33:19 (GMT)
commit8e475adf3052796b3fb644a6373b682b482bb13e (patch)
tree1ebf86b35ec8e5b81d1ec2c3580bdb4f5d99f604 /Lib/test/test_asyncio
parent08ce791f94618a6f553a9017fcaf5b84e85cb602 (diff)
downloadcpython-8e475adf3052796b3fb644a6373b682b482bb13e.zip
cpython-8e475adf3052796b3fb644a6373b682b482bb13e.tar.gz
cpython-8e475adf3052796b3fb644a6373b682b482bb13e.tar.bz2
gh-98703: Add tests for closing `_ProactorSocketTransport` with proactor event loop (GH-98730)
(cherry picked from commit 96ae80f1d004f2df4a707919853f0745c9c352d1) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Diffstat (limited to 'Lib/test/test_asyncio')
-rw-r--r--Lib/test/test_asyncio/test_proactor_events.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_proactor_events.py b/Lib/test/test_asyncio/test_proactor_events.py
index 7fd8b26..ae30185 100644
--- a/Lib/test/test_asyncio/test_proactor_events.py
+++ b/Lib/test/test_asyncio/test_proactor_events.py
@@ -297,6 +297,27 @@ class ProactorSocketTransportTests(test_utils.TestCase):
# 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']