From ad1cea608f714b438527abc5af26fb8074da5958 Mon Sep 17 00:00:00 2001 From: Mohammad Reza <34370960+azibom@users.noreply.github.com> Date: Fri, 24 Jul 2026 17:34:04 +0330 Subject: [PATCH] gh-150361: add test for FlowControlMixin pause_writing exception handling (#150362) --- Lib/test/test_asyncio/test_transports.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Lib/test/test_asyncio/test_transports.py b/Lib/test/test_asyncio/test_transports.py index 5e743345028b..12f6e40f1595 100644 --- a/Lib/test/test_asyncio/test_transports.py +++ b/Lib/test/test_asyncio/test_transports.py @@ -98,6 +98,29 @@ class TransportTests(unittest.TestCase): 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, -- 2.47.3