test_tutorial003.py
imports app from docs_src.websockets.tutorial003imports docs_src.websockets.tutorial003
SHA-25601992b43917b6390f87526e64a3a159e6c1904b0f10d3ef7fcb8e56246348032
MaleculeH(Cm)Md(In₃)
Evidence
1from fastapi.testclient import TestClient
2
3from docs_src.websockets.tutorial003 import app, html
4
5client = TestClient(app)
6
7
8def test_get():
9 response = client.get("/")
10 assert response.text == html
11
12
13def test_websocket_handle_disconnection():
14 with client.websocket_connect("/ws/1234") as connection, client.websocket_connect(
15 "/ws/5678 …
⋯7 lines
25 connection_two.close()
26 data1 = connection.receive_text()
27 assert data1 == "Client #5678 left the chat"