Skip to content

Commit

Permalink
test(test_ws.py): fix one async race potentially yielding unexpected …
Browse files Browse the repository at this point in the history
…result
  • Loading branch information
vytas7 committed Oct 14, 2023
1 parent 937ca9f commit fbac12a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/asgi/test_ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,13 @@ async def on_websocket(self, req, ws):
await resource.data_received.wait()
assert resource.data == sample_data

# NOTE(vytas): When testing the case where the server
# explicitly closes the connection, try to receive some data
# before closing from the client side (and potentially
# winning the async race of which side closes first).
if explicit_close_server:
await ws.receive_data()

if explicit_close_client:
await ws.close(4042)

Expand Down

0 comments on commit fbac12a

Please sign in to comment.