@@ -74,18 +74,21 @@ def test_connect_timeout(_socket, conn):
74
74
75
75
76
76
def test_blacked_out (conn ):
77
- assert conn .blacked_out () is False
78
- conn .last_attempt = time .time ()
79
- assert conn .blacked_out () is True
77
+ with mock .patch ("time.time" , return_value = 1000 ):
78
+ conn .last_attempt = 0
79
+ assert conn .blacked_out () is False
80
+ conn .last_attempt = 1000
81
+ assert conn .blacked_out () is True
80
82
81
83
82
84
def test_connection_delay (conn ):
83
- conn .last_attempt = time .time ()
84
- assert round (conn .connection_delay ()) == round (conn .config ['reconnect_backoff_ms' ])
85
- conn .state = ConnectionStates .CONNECTING
86
- assert conn .connection_delay () == 0
87
- conn .state = ConnectionStates .CONNECTED
88
- assert conn .connection_delay () == float ('inf' )
85
+ with mock .patch ("time.time" , return_value = 1000 ):
86
+ conn .last_attempt = 1000
87
+ assert conn .connection_delay () == conn .config ['reconnect_backoff_ms' ]
88
+ conn .state = ConnectionStates .CONNECTING
89
+ assert conn .connection_delay () == 0
90
+ conn .state = ConnectionStates .CONNECTED
91
+ assert conn .connection_delay () == float ('inf' )
89
92
90
93
91
94
def test_connected (conn ):
0 commit comments