Skip to content

Commit

Permalink
[PR #9055/11a96fcc backport][3.10] Add xfail test for issue #5180 (#9059
Browse files Browse the repository at this point in the history
)

Co-authored-by: J. Nick Koston <[email protected]>
  • Loading branch information
patchback[bot] and bdraco authored Sep 7, 2024
1 parent f631015 commit d049f4d
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 @@ -1119,3 +1119,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 d049f4d

Please sign in to comment.