File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -98,6 +98,29 @@ def get_write_buffer_size(self):
9898 self .assertTrue (transport ._protocol_paused )
9999 self .assertEqual (transport .get_write_buffer_limits (), (128 , 256 ))
100100
101+ def test_flowcontrol_mixin_pause_writing_exception (self ):
102+
103+ class MyTransport (transports ._FlowControlMixin ,
104+ transports .Transport ):
105+
106+ def get_write_buffer_size (self ):
107+ return 2000
108+
109+ loop = mock .Mock ()
110+ transport = MyTransport (loop = loop )
111+ protocol = mock .Mock ()
112+ protocol .pause_writing .side_effect = RuntimeError ("boom" )
113+ transport ._protocol = protocol
114+ transport .set_write_buffer_limits (high = 1000 , low = 100 )
115+ transport ._maybe_pause_protocol ()
116+ protocol .pause_writing .assert_called_once ()
117+ loop .call_exception_handler .assert_called_once ()
118+ args = loop .call_exception_handler .call_args [0 ][0 ]
119+
120+ self .assertIn ("protocol.pause_writing() failed" , args ["message" ])
121+ self .assertIsInstance (args ["exception" ], RuntimeError )
122+ self .assertTrue (transport ._protocol_paused )
123+
101124 def test_flowcontrol_mixin_compute_write_limits (self ):
102125
103126 class MyTransport (transports ._FlowControlMixin ,
You can’t perform that action at this time.
0 commit comments