Skip to content

Commit 946523d

Browse files
Fix flaky websocket test (#7902) (#7904)
(cherry picked from commit 28d0b06)
1 parent ddc2a26 commit 946523d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tests/test_client_ws_functional.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import aiohttp
77
from aiohttp import hdrs, web
8+
from aiohttp.http import WSCloseCode
89

910
if sys.version_info >= (3, 11):
1011
import asyncio as async_timeout
@@ -581,12 +582,12 @@ async def handler(request):
581582
app.router.add_route("GET", "/", handler)
582583

583584
client = await aiohttp_client(app)
584-
resp = await client.ws_connect("/", heartbeat=0.05)
585-
586-
await resp.receive()
587-
await resp.receive()
585+
resp = await client.ws_connect("/", heartbeat=0.1)
588586

587+
# Connection should be closed roughly after 1.5x heartbeat.
588+
await asyncio.sleep(0.2)
589589
assert ping_received
590+
assert resp.close_code is WSCloseCode.ABNORMAL_CLOSURE
590591

591592

592593
async def test_send_recv_compress(aiohttp_client) -> None:

0 commit comments

Comments
 (0)