mirror of https://github.com/tiangolo/fastapi.git
♻️ Refactor test names and files to simplify
This commit is contained in:
parent
088b157a98
commit
145d1de598
|
|
@ -11,16 +11,17 @@ app = FastAPI()
|
|||
client = TestClient(app)
|
||||
|
||||
|
||||
class Test:
|
||||
class Dep:
|
||||
def __call__(self, request: Request):
|
||||
return "test"
|
||||
|
||||
|
||||
@needs_py310
|
||||
def test_call():
|
||||
@app.get("/test/")
|
||||
def call(test: str = Depends(Test())):
|
||||
return {"test": test}
|
||||
@app.get("/test/")
|
||||
def call(test: str = Depends(Dep())):
|
||||
return {"test": test}
|
||||
|
||||
|
||||
@needs_py310
|
||||
def test_stringified_annotations():
|
||||
response = client.get("/test")
|
||||
assert response.status_code == 200
|
||||
|
|
@ -7,7 +7,7 @@ from fastapi.testclient import TestClient
|
|||
from pydantic import BaseModel
|
||||
|
||||
from ..utils import needs_py310
|
||||
from .login_tool import login_required
|
||||
from .wrapper import wrap
|
||||
|
||||
app = FastAPI()
|
||||
client = TestClient(app)
|
||||
|
|
@ -21,9 +21,9 @@ class Item(BaseModel):
|
|||
|
||||
|
||||
@needs_py310
|
||||
def test_future_6465():
|
||||
def test_stringified_annotations_import():
|
||||
@app.get("/items/")
|
||||
@login_required
|
||||
@wrap
|
||||
def get_item(item_id: int) -> Item:
|
||||
return Item(name="name", price=42.42)
|
||||
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
from functools import wraps
|
||||
|
||||
|
||||
def login_required(func):
|
||||
def wrap(func):
|
||||
@wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
# login functionality could come here
|
||||
return func(*args, **kwargs)
|
||||
|
||||
return wrapper
|
||||
Loading…
Reference in New Issue