Skip to content

Commit

Permalink
Add xfail test for issue #5180 (#9055)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Sep 7, 2024
1 parent 5f5a4d2 commit 11a96fc
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/test_web_websocket_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -1150,3 +1150,23 @@ async def on_shutdown(app: web.Application) -> None:
assert reply.extra == "Server shutdown"

assert websocket.closed is True


@pytest.mark.xfail(reason="close never reaches client per issue #5180")
async def test_ws_close_return_code(aiohttp_client: AiohttpClient) -> None:
"""Test that the close code is returned when the server closes the connection."""

async def handler(request: web.Request) -> web.WebSocketResponse:
ws = web.WebSocketResponse()
await ws.prepare(request)
await ws.close()
return ws

app = web.Application()
app.router.add_route("GET", "/", handler)
client = await aiohttp_client(app)
resp = await client.ws_connect("/")
await resp.send_str("some data")
await asyncio.sleep(0.1)
await resp.receive()
assert resp.close_code is WSCloseCode.OK

0 comments on commit 11a96fc

Please sign in to comment.