https://github.com/python/cpython/commit/ad1cea608f714b438527abc5af26fb8074da5958
commit: ad1cea608f714b438527abc5af26fb8074da5958
branch: main
author: Mohammad Reza <[email protected]>
committer: kumaraditya303 <[email protected]>
date: 2026-07-24T14:04:04Z
summary:

gh-150361: add test for FlowControlMixin pause_writing exception handling 
(#150362)

files:
M Lib/test/test_asyncio/test_transports.py

diff --git a/Lib/test/test_asyncio/test_transports.py 
b/Lib/test/test_asyncio/test_transports.py
index 5e743345028bec..12f6e40f1595fd 100644
--- a/Lib/test/test_asyncio/test_transports.py
+++ b/Lib/test/test_asyncio/test_transports.py
@@ -98,6 +98,29 @@ def get_write_buffer_size(self):
         self.assertTrue(transport._protocol_paused)
         self.assertEqual(transport.get_write_buffer_limits(), (128, 256))
 
+    def test_flowcontrol_mixin_pause_writing_exception(self):
+
+        class MyTransport(transports._FlowControlMixin,
+                          transports.Transport):
+
+            def get_write_buffer_size(self):
+                return 2000
+
+        loop = mock.Mock()
+        transport = MyTransport(loop=loop)
+        protocol = mock.Mock()
+        protocol.pause_writing.side_effect = RuntimeError("boom")
+        transport._protocol = protocol
+        transport.set_write_buffer_limits(high=1000, low=100)
+        transport._maybe_pause_protocol()
+        protocol.pause_writing.assert_called_once()
+        loop.call_exception_handler.assert_called_once()
+        args = loop.call_exception_handler.call_args[0][0]
+
+        self.assertIn("protocol.pause_writing() failed", args["message"])
+        self.assertIsInstance(args["exception"], RuntimeError)
+        self.assertTrue(transport._protocol_paused)
+
     def test_flowcontrol_mixin_compute_write_limits(self):
 
         class MyTransport(transports._FlowControlMixin,

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to