2025-12-04 09:18:32 +01:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
2025-12-17 13:25:59 -08:00
|
|
|
from typing import Annotated
|
|
|
|
|
|
2025-12-04 09:18:32 +01:00
|
|
|
from fastapi import Depends, FastAPI, Request
|
|
|
|
|
from fastapi.testclient import TestClient
|
|
|
|
|
|
|
|
|
|
from .utils import needs_py310
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Dep:
|
|
|
|
|
def __call__(self, request: Request):
|
|
|
|
|
return "test"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@needs_py310
|
|
|
|
|
def test_stringified_annotations():
|
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
|
|
|
|
client = TestClient(app)
|
|
|
|
|
|
|
|
|
|
@app.get("/test/")
|
|
|
|
|
def call(test: Annotated[str, Depends(Dep())]):
|
|
|
|
|
return {"test": test}
|
|
|
|
|
|
|
|
|
|
response = client.get("/test")
|
|
|
|
|
assert response.status_code == 200
|