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

Function test_application_close

tests/test_websockets.py:283–293  ·  tests/test_websockets.py::test_application_close
(test_client_factory: TestClientFactory)

Source from the content-addressed store, hash-verified

281
282
283def test_application_close(test_client_factory: TestClientFactory) -> None:
284 async def app(scope: Scope, receive: Receive, send: Send) -> None:
285 websocket = WebSocket(scope, receive=receive, send=send)
286 await websocket.accept()
287 await websocket.close(status.WS_1001_GOING_AWAY)
288
289 client = test_client_factory(app)
290 with client.websocket_connect(class="st">"/") as websocket:
291 with pytest.raises(WebSocketDisconnect) as exc:
292 websocket.receive_text()
293 assert exc.value.code == status.WS_1001_GOING_AWAY
294
295
296def test_rejected_connection(test_client_factory: TestClientFactory) -> None:

Callers

nothing calls this directly

Calls 3

receive_textMethod · 0.95
test_client_factoryFunction · 0.85
websocket_connectMethod · 0.80

Tested by

no test coverage detected