Coverage for tests/test_tutorial/test_custom_request_and_route/test_tutorial003.py: 100%
12 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
1from fastapi.testclient import TestClient 1abcde
3from docs_src.custom_request_and_route.tutorial003 import app 1abcde
5client = TestClient(app) 1abcde
8def test_get(): 1abcde
9 response = client.get("/") 1abcde
10 assert response.json() == {"message": "Not timed"} 1abcde
11 assert "X-Response-Time" not in response.headers 1abcde
14def test_get_timed(): 1abcde
15 response = client.get("/timed") 1abcde
16 assert response.json() == {"message": "It's the time of my life"} 1abcde
17 assert "X-Response-Time" in response.headers 1abcde
18 assert float(response.headers["X-Response-Time"]) >= 0 1abcde