import asyncio import websockets import re async def test(): async with websockets.connect("ws://localhost:8080") as ws: response = await ws.recv() assert(response == "HOSTJOIN:") await ws.send("HOST:") response = await ws.recv() assert(re.match(r"(\d|[a-f]){6}", response)) asyncio.get_event_loop().run_until_complete(test()) print("All tests passed")