Browse Source

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

pull/11355/head
Sebastián Ramírez 8 months ago
parent
commit
a06dc7a9ba
  1. 0
      tests/test_stringified_annotations/__init__.py
  2. 31
      tests/test_stringified_annotations/test_stringified_annotations_with_import.py
  3. 9
      tests/test_stringified_annotations/wrapper.py
  4. 5
      tests/test_stringified_annotations_simple.py

0
tests/test_stringified_annotations/__init__.py

31
tests/test_stringified_annotations/test_stringified_annotations_with_import.py

@ -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

9
tests/test_stringified_annotations/wrapper.py

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

5
tests/test_stringified_annotations/test_stringified_annotations_simple.py → 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}
Loading…
Cancel
Save