-
First Check
Commit to Help
Example Codefrom fastapi import FastAPI, HTTPException
app = FastAPI()
@app.websocket("/process/dummy_ws")
async def websocket_dummy(websocket: WebSocket):
await websocket.accept()
data = await websocket.receive_text()
while True:
await websocket.send_text(data)
await asyncio.sleep(0.1)DescriptionI'm trying to test the example simple Webscoket using the following pytest test. from app.main import app
from fastapi.testclient import TestClient
import pytest
@pytest.fixture()
def client():
yield TestClient(app)
def test_dummy_ws(client):
with client.websocket_connect("/process/dummy_ws") as websocket:
websocket.send_text("test")
data = websocket.receive_text()
assert data == "test"The test hangs forever and never finishes. Is there something missing im not aware of? Operating SystemLinux Operating System DetailsNo response FastAPI Version0.103.2 Pydantic Version2.6.1 Python VersionPython 3.8.10 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Answered by
Kludex
Feb 13, 2024
Replies: 1 comment 1 reply
-
|
Bump to the latest FastAPI. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Kludex
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bump to the latest FastAPI.