Debian Codegraph @

tests/test_stringified_annotations_simple.py

raw
1 from __future__ import annotations
2
3 from typing import Annotated
4
5 from fastapi import Depends, FastAPI, Request
6 from fastapi.testclient import TestClient
7
8 from .utils import needs_py310
9
10
11 class Dep:
12 def __call__(self, request: Request):
13 return "test"
14
15
16 @needs_py310
17 def test_stringified_annotations():
18 app = FastAPI()
19
20 client = TestClient(app)
21
22 @app.get("/test/")
23 def call(test: Annotated[str, Depends(Dep())]):
24 return {"test": test}
25
26 response = client.get("/test")
27 assert response.status_code == 200