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

Function test_receive_before_accept

tests/test_websockets.py:631–641  ·  tests/test_websockets.py::test_receive_before_accept
(test_client_factory: TestClientFactory)

Source from the content-addressed store, hash-verified

629
630
631def test_receive_before_accept(test_client_factory: TestClientFactory) -> None:
632 async def app(scope: Scope, receive: Receive, send: Send) -> None:
633 websocket = WebSocket(scope, receive=receive, send=send)
634 await websocket.accept()
635 websocket.client_state = WebSocketState.CONNECTING
636 await websocket.receive()
637
638 client = test_client_factory(app)
639 with pytest.raises(RuntimeError):
640 with client.websocket_connect(class="st">"/") as websocket:
641 websocket.send({class="st">"type": class="st">"websocket.send"})
642
643
644def test_receive_wrong_message_type(test_client_factory: TestClientFactory) -> None:

Callers

nothing calls this directly

Calls 3

sendMethod · 0.95
test_client_factoryFunction · 0.85
websocket_connectMethod · 0.80

Tested by

no test coverage detected