Coverage for tests/test_include_route.py: 100%
14 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 import APIRouter, FastAPI, Request 1abcdef
2from fastapi.responses import JSONResponse 1abcdef
3from fastapi.testclient import TestClient 1abcdef
5app = FastAPI() 1abcdef
6router = APIRouter() 1abcdef
9@router.route("/items/") 1abcdef
10def read_items(request: Request): 1abcdef
11 return JSONResponse({"hello": "world"}) 1ghijkl
14app.include_router(router) 1abcdef
16client = TestClient(app) 1abcdef
19def test_sub_router(): 1abcdef
20 response = client.get("/items/") 1ghijkl
21 assert response.status_code == 200, response.text 1ghijkl
22 assert response.json() == {"hello": "world"} 1ghijkl