File tree 1 file changed +21
-0
lines changed
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -297,6 +297,27 @@ def test_force_close_idempotent(self):
297
297
# and waiters will never be notified leading to hang.
298
298
self .assertTrue (self .protocol .connection_lost .called )
299
299
300
+ def test_force_close_protocol_connection_lost_once (self ):
301
+ tr = self .socket_transport ()
302
+ self .assertFalse (self .protocol .connection_lost .called )
303
+ tr ._closing = True
304
+ # Calling _force_close twice should not call
305
+ # protocol.connection_lost twice
306
+ tr ._force_close (None )
307
+ tr ._force_close (None )
308
+ test_utils .run_briefly (self .loop )
309
+ self .assertEqual (1 , self .protocol .connection_lost .call_count )
310
+
311
+ def test_close_protocol_connection_lost_once (self ):
312
+ tr = self .socket_transport ()
313
+ self .assertFalse (self .protocol .connection_lost .called )
314
+ # Calling close twice should not call
315
+ # protocol.connection_lost twice
316
+ tr .close ()
317
+ tr .close ()
318
+ test_utils .run_briefly (self .loop )
319
+ self .assertEqual (1 , self .protocol .connection_lost .call_count )
320
+
300
321
def test_fatal_error_2 (self ):
301
322
tr = self .socket_transport ()
302
323
tr ._buffer = [b'data' ]
You can’t perform that action at this time.
0 commit comments