- Sort Score
- Result 10 results
- Languages All
Results 1 - 8 of 8 for websocket_connect (1.92 sec)
-
tests/test_dependency_yield_scope_websockets.py
global_state = global_context.get() with client.websocket_connect("/function-scope") as websocket: data = websocket.receive_json() assert data["is_open"] is True assert global_state["session_closed"] is True def test_request_scope() -> None: global_context.set({}) global_state = global_context.get() with client.websocket_connect("/request-scope") as websocket:
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 21:25:59 UTC 2025 - 6K bytes - Viewed (0) -
tests/test_tutorial/test_websockets/test_tutorial002.py
with pytest.raises(WebSocketDisconnect): with client.websocket_connect("/items/foo/ws"): pytest.fail( "did not raise WebSocketDisconnect on __enter__" ) # pragma: no cover def test_websocket_invalid_data(app: FastAPI): client = TestClient(app) with pytest.raises(WebSocketDisconnect): with client.websocket_connect("/items/foo/ws?q=bar&token=some-token"):
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 20:41:43 UTC 2025 - 4.1K bytes - Viewed (0) -
tests/test_tutorial/test_websockets/test_tutorial003.py
response = client.get("/") assert response.text == html def test_websocket_handle_disconnection(client: TestClient): with ( client.websocket_connect("/ws/1234") as connection, client.websocket_connect("/ws/5678") as connection_two, ): connection.send_text("Hello from 1234") data1 = connection.receive_text() assert data1 == "You wrote: Hello from 1234"
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 21:25:59 UTC 2025 - 1.3K bytes - Viewed (0) -
tests/test_dependency_after_yield_websockets.py
for item in session: await websocket.send_text(f"{item}") # pragma no cover client = TestClient(app) def test_websocket_dependency_after_yield(): with client.websocket_connect("/ws") as websocket: data = websocket.receive_text() assert data == "foo" data = websocket.receive_text() assert data == "bar" data = websocket.receive_text()Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 21:25:59 UTC 2025 - 2K bytes - Viewed (0) -
tests/test_ws_dependencies.py
) def test_index(): client = TestClient(app) with client.websocket_connect("/") as websocket: data = json.loads(websocket.receive_text()) assert data == ["app", "index"] def test_routerindex(): client = TestClient(app) with client.websocket_connect("/router") as websocket: data = json.loads(websocket.receive_text())
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 21:25:59 UTC 2025 - 2.1K bytes - Viewed (0) -
docs_src/app_testing/tutorial002_py39.py
response = client.get("/") assert response.status_code == 200 assert response.json() == {"msg": "Hello World"} def test_websocket(): client = TestClient(app) with client.websocket_connect("/ws") as websocket: data = websocket.receive_json()
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 20:41:43 UTC 2025 - 757 bytes - Viewed (0) -
tests/test_validation_error_context.py
assert "get_item" in error_str assert "/items/" in error_str def test_websocket_validation_error_includes_endpoint_context(): captured_exception.exception = None try: with client.websocket_connect("/ws/invalid"): pass # pragma: no cover except Exception: pass assert captured_exception.exception is not None error_str = str(captured_exception.exception)
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Dec 06 12:21:57 UTC 2025 - 4.7K bytes - Viewed (0) -
tests/test_tutorial/test_websockets/test_tutorial001.py
assert response.status_code == 200, response.text assert b"<!DOCTYPE html>" in response.content def test_websocket(): with pytest.raises(WebSocketDisconnect): with client.websocket_connect("/ws") as websocket: message = "Message one" websocket.send_text(message) data = websocket.receive_text() assert data == f"Message text was: {message}"Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 20:41:43 UTC 2025 - 827 bytes - Viewed (0)