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

Function test_websocket_endpoint_on_disconnect

tests/test_endpoints.py:168–178  ·  tests/test_endpoints.py::test_websocket_endpoint_on_disconnect
(
    test_client_factory: TestClientFactory,
)

Source from the content-addressed store, hash-verified

166
167
168def test_websocket_endpoint_on_disconnect(
169 test_client_factory: TestClientFactory,
170) -> None:
171 class WebSocketApp(WebSocketEndpoint):
172 async def on_disconnect(self, websocket: WebSocket, close_code: int) -> None:
173 assert close_code == 1001
174 await websocket.close(code=close_code)
175
176 client = test_client_factory(WebSocketApp)
177 with client.websocket_connect(class="st">"/ws") as websocket:
178 websocket.close(code=1001)

Callers

nothing calls this directly

Calls 3

test_client_factoryFunction · 0.85
websocket_connectMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected