(test_client_factory: TestClientFactory)
| 535 | |
| 536 | |
| 537 | def test_websocket_close_reason(test_client_factory: TestClientFactory) -> None: |
| 538 | async def app(scope: Scope, receive: Receive, send: Send) -> None: |
| 539 | websocket = WebSocket(scope, receive=receive, send=send) |
| 540 | await websocket.accept() |
| 541 | await websocket.close(code=status.WS_1001_GOING_AWAY, reason="Going Away") |
| 542 | |
| 543 | client = test_client_factory(app) |
| 544 | with client.websocket_connect("/") as websocket: |
| 545 | with pytest.raises(WebSocketDisconnect) as exc: |
| 546 | websocket.receive_text() |
| 547 | assert exc.value.code == status.WS_1001_GOING_AWAY |
| 548 | assert exc.value.reason == "Going Away" |
| 549 | |
| 550 | |
| 551 | def test_send_json_invalid_mode(test_client_factory: TestClientFactory) -> None: |
nothing calls this directly
no test coverage detected