diff --git a/tests/test_tutorial/test_websockets/test_tutorial003.py b/tests/test_tutorial/test_websockets/test_tutorial003.py index 781146371d..f481e84334 100644 --- a/tests/test_tutorial/test_websockets/test_tutorial003.py +++ b/tests/test_tutorial/test_websockets/test_tutorial003.py @@ -1,4 +1,5 @@ import importlib +import time from types import ModuleType import pytest @@ -42,11 +43,13 @@ def test_websocket_handle_disconnection(client: TestClient): connection.send_text("Hello from 1234") data1 = connection.receive_text() assert data1 == "You wrote: Hello from 1234" + time.sleep(0.01) # Give server time to process broadcast data2 = connection_two.receive_text() client1_says = "Client #1234 says: Hello from 1234" assert data2 == client1_says data1 = connection.receive_text() assert data1 == client1_says connection_two.close() + time.sleep(0.01) # Give server time to process broadcast data1 = connection.receive_text() assert data1 == "Client #5678 left the chat"