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

Function test_websocket_raise_http_exception

tests/test_applications.py:263–268  ·  view source on GitHub ↗
(client: TestClient)

Source from the content-addressed store, hash-verified

261
262
263def test_websocket_raise_http_exception(client: TestClient) -> None:
264 with pytest.raises(WebSocketDenialResponse) as exc:
265 with client.websocket_connect("/ws-raise-http"):
266 pass # pragma: no cover
267 assert exc.value.status_code == 401
268 assert exc.value.content == b'{"detail":"Unauthorized"}'
269
270
271def test_websocket_raise_custom_exception(client: TestClient) -> None:

Callers

nothing calls this directly

Calls 1

websocket_connectMethod · 0.80

Tested by

no test coverage detected