Skip to content

Commit

Permalink
Fix flaky websocket test (#7902)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamsorcerer authored Nov 25, 2023
1 parent 9a7cfe7 commit 28d0b06
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tests/test_client_ws_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import aiohttp
from aiohttp import hdrs, web
from aiohttp.client_ws import ClientWSTimeout
from aiohttp.http import WSCloseCode

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

client = await aiohttp_client(app)
resp = await client.ws_connect("/", heartbeat=0.05)

await resp.receive()
await resp.receive()
resp = await client.ws_connect("/", heartbeat=0.1)

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


async def test_send_recv_compress(aiohttp_client: Any) -> None:
Expand Down

0 comments on commit 28d0b06

Please sign in to comment.