diff --git a/tests/test_tutorial/test_middleware/__init__.py b/tests/test_tutorial/test_middleware/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/test_tutorial/test_middleware/test_tutorial001.py b/tests/test_tutorial/test_middleware/test_tutorial001.py new file mode 100644 index 000000000..8131f182c --- /dev/null +++ b/tests/test_tutorial/test_middleware/test_tutorial001.py @@ -0,0 +1,12 @@ +from docs_src.middleware.tutorial001 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 +