Coverage for tests / test_tutorial / test_advanced_middleware / test_tutorial002.py: 100%
12 statements
« prev ^ index » next coverage.py v7.13.3, created at 2026-04-06 01:24 +0000
« prev ^ index » next coverage.py v7.13.3, created at 2026-04-06 01:24 +0000
1from fastapi.testclient import TestClient 1efgh
3from docs_src.advanced_middleware.tutorial002_py310 import app 1efgh
6def test_middleware(): 1efgh
7 client = TestClient(app, base_url="http://example.com") 1abcd
8 response = client.get("/") 1abcd
9 assert response.status_code == 200, response.text 1abcd
10 client = TestClient(app, base_url="http://subdomain.example.com") 1abcd
11 response = client.get("/") 1abcd
12 assert response.status_code == 200, response.text 1abcd
13 client = TestClient(app, base_url="http://invalidhost") 1abcd
14 response = client.get("/") 1abcd
15 assert response.status_code == 400, response.text 1abcd