mirror of
https://github.com/fastapi/fastapi.git
synced 2026-01-21 12:30:49 -05:00
Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com> Co-authored-by: svlandeg <svlandeg@github.com> Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
27 lines
555 B
Python
27 lines
555 B
Python
from __future__ import annotations
|
|
|
|
from fastapi import Depends, FastAPI, Request
|
|
from fastapi.testclient import TestClient
|
|
from typing_extensions import Annotated
|
|
|
|
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
|