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

Function test_websocket_endpoint_on_default

tests/test_endpoints.py:154–165  ·  tests/test_endpoints.py::test_websocket_endpoint_on_default
(test_client_factory: TestClientFactory)

Source from the content-addressed store, hash-verified

152
153
154def test_websocket_endpoint_on_default(test_client_factory: TestClientFactory) -> None:
155 class WebSocketApp(WebSocketEndpoint):
156 encoding = None
157
158 async def on_receive(self, websocket: WebSocket, data: str) -> None:
159 await websocket.send_text(fclass="st">"Message text was: {data}")
160
161 client = test_client_factory(WebSocketApp)
162 with client.websocket_connect(class="st">"/ws") as websocket:
163 websocket.send_text(class="st">"Hello, world!")
164 _text = websocket.receive_text()
165 assert _text == class="st">"Message text was: Hello, world!"
166
167
168def test_websocket_endpoint_on_disconnect(

Callers

nothing calls this directly

Calls 4

test_client_factoryFunction · 0.85
websocket_connectMethod · 0.80
send_textMethod · 0.45
receive_textMethod · 0.45

Tested by

no test coverage detected