Coverage for tests/test_tutorial/test_advanced_middleware/test_tutorial002.py: 100%
12 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-05-05 00:03 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-05-05 00:03 +0000
1from fastapi.testclient import TestClient 1ghijkl
3from docs_src.advanced_middleware.tutorial002 import app 1ghijkl
6def test_middleware(): 1ghijkl
7 client = TestClient(app, base_url="http://example.com") 1abcdef
8 response = client.get("/") 1abcdef
9 assert response.status_code == 200, response.text 1abcdef
10 client = TestClient(app, base_url="http://subdomain.example.com") 1abcdef
11 response = client.get("/") 1abcdef
12 assert response.status_code == 200, response.text 1abcdef
13 client = TestClient(app, base_url="http://invalidhost") 1abcdef
14 response = client.get("/") 1abcdef
15 assert response.status_code == 400, response.text 1abcdef