diff --git a/tests/test_tutorial/test_middleware/test_tutorial002.py b/tests/test_tutorial/test_middleware/test_tutorial002.py new file mode 100644 index 000000000..6d8b975f0 --- /dev/null +++ b/tests/test_tutorial/test_middleware/test_tutorial002.py @@ -0,0 +1,11 @@ +from docs_src.middleware.tutorial002 import app +from fastapi.testclient import TestClient + + +def test_add_process_time_header_middleware(): + client = TestClient(app) + response = client.get("/") + assert response.status_code == 200 + assert response.json() == {"hello": "world"} + assert "X-Process-Time" in response.headers + assert len(response.headers["X-Process-Time"]) > 0