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