Attach updated endpoint signature to inner

Not all endpoints accept a __signature__ attribute, nor should the
cache decorator modify the decorated endpoint. Attach the signature
to the returned inner function instead.

While here, refactor the signature updating code, and extract it to
a separate function.
This commit is contained in:
Martijn Pieters
2023-04-27 18:14:59 +01:00
parent ee58f979d4
commit 832650347b
3 changed files with 52 additions and 27 deletions

View File

@@ -73,3 +73,9 @@ def test_kwargs() -> None:
name = "Jon"
response = client.get("/kwargs", params={"name": name})
assert response.json() == {"name": name}
def test_method() -> None:
with TestClient(app) as client:
response = client.get("/method")
assert response.json() == 17