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

Function test_websocket_url

tests/test_websockets.py:18–28  ·  tests/test_websockets.py::test_websocket_url
(test_client_factory: TestClientFactory)

Source from the content-addressed store, hash-verified

16
17
18def test_websocket_url(test_client_factory: TestClientFactory) -> None:
19 async def app(scope: Scope, receive: Receive, send: Send) -> None:
20 websocket = WebSocket(scope, receive=receive, send=send)
21 await websocket.accept()
22 await websocket.send_json({class="st">"url": str(websocket.url)})
23 await websocket.close()
24
25 client = test_client_factory(app)
26 with client.websocket_connect(class="st">"/123?a=abc") as websocket:
27 data = websocket.receive_json()
28 assert data == {class="st">"url": class="st">"ws://testserver/123?a=abc"}
29
30
31def test_websocket_binary_json(test_client_factory: TestClientFactory) -> None:

Callers

nothing calls this directly

Calls 3

receive_jsonMethod · 0.95
test_client_factoryFunction · 0.85
websocket_connectMethod · 0.80

Tested by

no test coverage detected