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

Function test_websocket_port

tests/test_websockets.py:105–115  ·  tests/test_websockets.py::test_websocket_port
(test_client_factory: TestClientFactory)

Source from the content-addressed store, hash-verified

103
104
105def test_websocket_port(test_client_factory: TestClientFactory) -> None:
106 async def app(scope: Scope, receive: Receive, send: Send) -> None:
107 websocket = WebSocket(scope, receive=receive, send=send)
108 await websocket.accept()
109 await websocket.send_json({class="st">"port": websocket.url.port})
110 await websocket.close()
111
112 client = test_client_factory(app)
113 with client.websocket_connect(class="st">"ws://example.com:123/123?a=abc") as websocket:
114 data = websocket.receive_json()
115 assert data == {class="st">"port": 123}
116
117
118def test_websocket_send_and_receive_text(

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