Skip to content

Commit

Permalink
retire offline test script in favor of first-class test case
Browse files Browse the repository at this point in the history
  • Loading branch information
belm0 committed Feb 14, 2019
1 parent 87c5f3f commit 3ae2587
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 111 deletions.
111 changes: 0 additions & 111 deletions tests/issue_96.py

This file was deleted.

20 changes: 20 additions & 0 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,3 +664,23 @@ async def handler(request):
await client.get_message()
assert client.closed
assert client.closed.code == 1009


async def test_close_race(nursery, autojump_clock):
"""server attempts close just as client disconnects (issue #96)"""

async def handler(request):
ws = await request.accept()
await ws.send_message('foo')
await ws._for_testing_peer_closed_connection.wait()
# with bug, this would raise ConnectionClosed from websocket internal task
await trio.aclose_forcefully(ws._stream)

server = await nursery.start(
partial(serve_websocket, handler, HOST, 0, ssl_context=None))

connection = await connect_websocket(nursery, HOST, server.port,
RESOURCE, use_ssl=False)
await connection.get_message()
await connection.aclose()
await trio.sleep(.1)

0 comments on commit 3ae2587

Please sign in to comment.