@@ -980,13 +980,14 @@ async def test_pong_unsupported_type(self):
980
980
@patch ("random.getrandbits" , return_value = 1918987876 )
981
981
async def test_keepalive (self , getrandbits ):
982
982
"""keepalive sends pings at ping_interval and measures latency."""
983
- self .connection .ping_interval = 2 * MS
983
+ self .connection .ping_interval = 3 * MS
984
984
self .connection .start_keepalive ()
985
+ self .assertIsNotNone (self .connection .keepalive_task )
985
986
self .assertEqual (self .connection .latency , 0 )
986
- # 2 ms: keepalive() sends a ping frame.
987
- # 2 .x ms: a pong frame is received.
988
- await asyncio .sleep (3 * MS )
989
- # 3 ms: check that the ping frame was sent.
987
+ # 3 ms: keepalive() sends a ping frame.
988
+ # 3 .x ms: a pong frame is received.
989
+ await asyncio .sleep (4 * MS )
990
+ # 4 ms: check that the ping frame was sent.
990
991
await self .assertFrameSent (Frame (Opcode .PING , b"rand" ))
991
992
self .assertGreater (self .connection .latency , 0 )
992
993
self .assertLess (self .connection .latency , MS )
@@ -995,8 +996,7 @@ async def test_disable_keepalive(self):
995
996
"""keepalive is disabled when ping_interval is None."""
996
997
self .connection .ping_interval = None
997
998
self .connection .start_keepalive ()
998
- await asyncio .sleep (3 * MS )
999
- await self .assertNoFrameSent ()
999
+ self .assertIsNone (self .connection .keepalive_task )
1000
1000
1001
1001
@patch ("random.getrandbits" , return_value = 1918987876 )
1002
1002
async def test_keepalive_times_out (self , getrandbits ):
0 commit comments