From a06dc7a9ba6b93d66af7980fc87c9de77df41bc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Wed, 3 Dec 2025 12:49:52 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20Remove=20test=20already=20passin?= =?UTF-8?q?g=20on=20master,=20refactor=20and=20simplify=20remaining=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test_stringified_annotations/__init__.py | 0 ...est_stringified_annotations_with_import.py | 31 ------------------- tests/test_stringified_annotations/wrapper.py | 9 ------ .../test_stringified_annotations_simple.py | 5 +-- 4 files changed, 3 insertions(+), 42 deletions(-) delete mode 100644 tests/test_stringified_annotations/__init__.py delete mode 100644 tests/test_stringified_annotations/test_stringified_annotations_with_import.py delete mode 100644 tests/test_stringified_annotations/wrapper.py rename tests/{test_stringified_annotations => }/test_stringified_annotations_simple.py (78%) diff --git a/tests/test_stringified_annotations/__init__.py b/tests/test_stringified_annotations/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/test_stringified_annotations/test_stringified_annotations_with_import.py b/tests/test_stringified_annotations/test_stringified_annotations_with_import.py deleted file mode 100644 index 824f378e3c..0000000000 --- a/tests/test_stringified_annotations/test_stringified_annotations_with_import.py +++ /dev/null @@ -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 diff --git a/tests/test_stringified_annotations/wrapper.py b/tests/test_stringified_annotations/wrapper.py deleted file mode 100644 index e7a0a42a24..0000000000 --- a/tests/test_stringified_annotations/wrapper.py +++ /dev/null @@ -1,9 +0,0 @@ -from functools import wraps - - -def wrap(func): - @wraps(func) - def wrapper(*args, **kwargs): - return func(*args, **kwargs) - - return wrapper diff --git a/tests/test_stringified_annotations/test_stringified_annotations_simple.py b/tests/test_stringified_annotations_simple.py similarity index 78% rename from tests/test_stringified_annotations/test_stringified_annotations_simple.py rename to tests/test_stringified_annotations_simple.py index 6f0b4b1990..49eefeeaba 100644 --- a/tests/test_stringified_annotations/test_stringified_annotations_simple.py +++ b/tests/test_stringified_annotations_simple.py @@ -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}