summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio
diff options
context:
space:
mode:
authorItayazolay <itayazolay@gmail.com>2023-04-27 10:03:29 (GMT)
committerGitHub <noreply@github.com>2023-04-27 10:03:29 (GMT)
commit78942ecd9b1dbbd95e99cc298b0154fe126dac12 (patch)
tree1f273bbaefcf0b51c4b714292925e2f963220871 /Lib/test/test_asyncio
parentdff8e5dc8d0758d1f9c55fdef308e44aefebe1a2 (diff)
downloadcpython-78942ecd9b1dbbd95e99cc298b0154fe126dac12.zip
cpython-78942ecd9b1dbbd95e99cc298b0154fe126dac12.tar.gz
cpython-78942ecd9b1dbbd95e99cc298b0154fe126dac12.tar.bz2
gh-103607: Fix `pause_reading` to work when called from `connection_made` in `asyncio`. (#17425)
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.py13
-rw-r--r--Lib/test/test_asyncio/test_selector_events.py16
2 files changed, 29 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_proactor_events.py b/Lib/test/test_asyncio/test_proactor_events.py
index 6cb7dc3..c42856e 100644
--- a/Lib/test/test_asyncio/test_proactor_events.py
+++ b/Lib/test/test_asyncio/test_proactor_events.py
@@ -447,6 +447,19 @@ class ProactorSocketTransportTests(test_utils.TestCase):
self.assertFalse(tr.is_reading())
+ def test_pause_reading_connection_made(self):
+ tr = self.socket_transport()
+ self.protocol.connection_made.side_effect = lambda _: tr.pause_reading()
+ test_utils.run_briefly(self.loop)
+ self.assertFalse(tr.is_reading())
+ self.loop.assert_no_reader(7)
+
+ tr.resume_reading()
+ self.assertTrue(tr.is_reading())
+
+ tr.close()
+ self.assertFalse(tr.is_reading())
+
def pause_writing_transport(self, high):
tr = self.socket_transport()
diff --git a/Lib/test/test_asyncio/test_selector_events.py b/Lib/test/test_asyncio/test_selector_events.py
index e41341f..47693ea 100644
--- a/Lib/test/test_asyncio/test_selector_events.py
+++ b/Lib/test/test_asyncio/test_selector_events.py
@@ -547,6 +547,22 @@ class SelectorSocketTransportTests(test_utils.TestCase):
self.assertFalse(tr.is_reading())
self.loop.assert_no_reader(7)
+ def test_pause_reading_connection_made(self):
+ tr = self.socket_transport()
+ self.protocol.connection_made.side_effect = lambda _: tr.pause_reading()
+ test_utils.run_briefly(self.loop)
+ self.assertFalse(tr.is_reading())
+ self.loop.assert_no_reader(7)
+
+ tr.resume_reading()
+ self.assertTrue(tr.is_reading())
+ self.loop.assert_reader(7, tr._read_ready)
+
+ tr.close()
+ self.assertFalse(tr.is_reading())
+ self.loop.assert_no_reader(7)
+
+
def test_read_eof_received_error(self):
transport = self.socket_transport()
transport.close = mock.Mock()