(
test_client_factory: TestClientFactory,
)
| 116 | |
| 117 | |
| 118 | def test_websocket_send_and_receive_text( |
| 119 | test_client_factory: TestClientFactory, |
| 120 | ) -> None: |
| 121 | async def app(scope: Scope, receive: Receive, send: Send) -> None: |
| 122 | websocket = WebSocket(scope, receive=receive, send=send) |
| 123 | await websocket.accept() |
| 124 | data = await websocket.receive_text() |
| 125 | await websocket.send_text("Message was: " + data) |
| 126 | await websocket.close() |
| 127 | |
| 128 | client = test_client_factory(app) |
| 129 | with client.websocket_connect("/") as websocket: |
| 130 | websocket.send_text("Hello, world!") |
| 131 | data = websocket.receive_text() |
| 132 | assert data == "Message was: Hello, world!" |
| 133 | |
| 134 | |
| 135 | def test_websocket_send_and_receive_bytes( |
nothing calls this directly
no test coverage detected