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

Function test_websocket_iter_text

tests/test_websockets.py:169–180  ·  view source on GitHub ↗
(test_client_factory: TestClientFactory)

Source from the content-addressed store, hash-verified

167
168
169def test_websocket_iter_text(test_client_factory: TestClientFactory) -> None:
170 async def app(scope: Scope, receive: Receive, send: Send) -> None:
171 websocket = WebSocket(scope, receive=receive, send=send)
172 await websocket.accept()
173 async for data in websocket.iter_text():
174 await websocket.send_text("Message was: " + data)
175
176 client = test_client_factory(app)
177 with client.websocket_connect("/") as websocket:
178 websocket.send_text("Hello, world!")
179 data = websocket.receive_text()
180 assert data == "Message was: Hello, world!"
181
182
183def test_websocket_iter_bytes(test_client_factory: TestClientFactory) -> None:

Callers

nothing calls this directly

Calls 4

send_textMethod · 0.95
receive_textMethod · 0.95
test_client_factoryFunction · 0.85
websocket_connectMethod · 0.80

Tested by

no test coverage detected