mirror of https://github.com/tiangolo/fastapi.git
Move ForwardRef annotated dependency test to dedicated module
This commit is contained in:
parent
49daf31abd
commit
dc0029f114
|
|
@ -0,0 +1,23 @@
|
|||
from typing import Annotated, ForwardRef
|
||||
|
||||
from fastapi import Depends, FastAPI
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
|
||||
def test_annotated_forwardref_dependency():
|
||||
app = FastAPI()
|
||||
|
||||
User = ForwardRef("User")
|
||||
|
||||
def get_user() -> "User":
|
||||
return {"name": "amulya"}
|
||||
|
||||
@app.get("/")
|
||||
def read_user(user: Annotated[User, Depends(get_user)]):
|
||||
return user
|
||||
|
||||
client = TestClient(app)
|
||||
response = client.get("/")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {"name": "amulya"}
|
||||
Loading…
Reference in New Issue