Skip to content

Commit 28d0b06

Browse files
Fix flaky websocket test (#7902)
1 parent 9a7cfe7 commit 28d0b06

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
@@ -8,6 +8,7 @@
88
import aiohttp
99
from aiohttp import hdrs, web
1010
from aiohttp.client_ws import ClientWSTimeout
11+
from aiohttp.http import WSCloseCode
1112

1213
if sys.version_info >= (3, 11):
1314
import asyncio as async_timeout
@@ -643,12 +644,12 @@ async def handler(request):
643644
app.router.add_route("GET", "/", handler)
644645

645646
client = await aiohttp_client(app)
646-
resp = await client.ws_connect("/", heartbeat=0.05)
647-
648-
await resp.receive()
649-
await resp.receive()
647+
resp = await client.ws_connect("/", heartbeat=0.1)
650648

649+
# Connection should be closed roughly after 1.5x heartbeat.
650+
await asyncio.sleep(0.2)
651651
assert ping_received
652+
assert resp.close_code is WSCloseCode.ABNORMAL_CLOSURE
652653

653654

654655
async def test_send_recv_compress(aiohttp_client: Any) -> None:

0 commit comments

Comments
 (0)