MCPcopy
hub / github.com/encode/starlette / test_duplicate_disconnect

Function test_duplicate_disconnect

tests/test_websockets.py:496–507  ·  view source on GitHub ↗
(test_client_factory: TestClientFactory)

Source from the content-addressed store, hash-verified

494
495
496def test_duplicate_disconnect(test_client_factory: TestClientFactory) -> None:
497 async def app(scope: Scope, receive: Receive, send: Send) -> None:
498 websocket = WebSocket(scope, receive=receive, send=send)
499 await websocket.accept()
500 message = await websocket.receive()
501 assert message["type"] == "websocket.disconnect"
502 message = await websocket.receive()
503
504 client = test_client_factory(app)
505 with pytest.raises(RuntimeError):
506 with client.websocket_connect("/") as websocket:
507 websocket.close()
508
509
510def test_websocket_scope_interface() -> None:

Callers

nothing calls this directly

Calls 3

closeMethod · 0.95
test_client_factoryFunction · 0.85
websocket_connectMethod · 0.80

Tested by

no test coverage detected