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

Function test_websocket_iter_bytes

tests/test_websockets.py:183–194  ·  tests/test_websockets.py::test_websocket_iter_bytes
(test_client_factory: TestClientFactory)

Source from the content-addressed store, hash-verified

181
182
183def test_websocket_iter_bytes(test_client_factory: TestClientFactory) -> None:
184 async def app(scope: Scope, receive: Receive, send: Send) -> None:
185 websocket = WebSocket(scope, receive=receive, send=send)
186 await websocket.accept()
187 async for data in websocket.iter_bytes():
188 await websocket.send_bytes(bclass="st">"Message was: " + data)
189
190 client = test_client_factory(app)
191 with client.websocket_connect(class="st">"/") as websocket:
192 websocket.send_bytes(bclass="st">"Hello, world!")
193 data = websocket.receive_bytes()
194 assert data == bclass="st">"Message was: Hello, world!"
195
196
197def test_websocket_iter_json(test_client_factory: TestClientFactory) -> None:

Callers

nothing calls this directly

Calls 4

send_bytesMethod · 0.95
receive_bytesMethod · 0.95
test_client_factoryFunction · 0.85
websocket_connectMethod · 0.80

Tested by

no test coverage detected