🔥 Remove test already passing on master, refactor and simplify remaining test

This commit is contained in:
Sebastián Ramírez 2025-12-03 12:49:52 +01:00
parent 145d1de598
commit a06dc7a9ba
4 changed files with 3 additions and 42 deletions

View File

@ -1,31 +0,0 @@
from __future__ import annotations
from typing import Optional
from fastapi import FastAPI
from fastapi.testclient import TestClient
from pydantic import BaseModel
from ..utils import needs_py310
from .wrapper import wrap
app = FastAPI()
client = TestClient(app)
class Item(BaseModel):
name: str
description: Optional[str] = None
price: float
tax: Optional[float] = None
@needs_py310
def test_stringified_annotations_import():
@app.get("/items/")
@wrap
def get_item(item_id: int) -> Item:
return Item(name="name", price=42.42)
res = client.get("/items?item_id=3")
assert res.status_code == 200

View File

@ -1,9 +0,0 @@
from functools import wraps
def wrap(func):
@wraps(func)
def wrapper(*args, **kwargs):
return func(*args, **kwargs)
return wrapper

View File

@ -3,8 +3,9 @@ from __future__ import annotations
from fastapi import Depends, FastAPI
from fastapi.testclient import TestClient
from starlette.requests import Request
from typing_extensions import Annotated
from ..utils import needs_py310
from .utils import needs_py310
app = FastAPI()
@ -17,7 +18,7 @@ class Dep:
@app.get("/test/")
def call(test: str = Depends(Dep())):
def call(test: Annotated[str, Depends(Dep())]):
return {"test": test}