Files
fastapi/tests/test_callable_endpoint.py
Sebastián Ramírez faee822574 🎨 Upgrade typing syntax for Python 3.10 (#14932)
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: tiangolo <1326112+tiangolo@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-02-17 09:59:14 +00:00

25 lines
426 B
Python

from functools import partial
from fastapi import FastAPI
from fastapi.testclient import TestClient
def main(some_arg, q: str | None = None):
return {"some_arg": some_arg, "q": q}
endpoint = partial(main, "foo")
app = FastAPI()
app.get("/")(endpoint)
client = TestClient(app)
def test_partial():
response = client.get("/?q=bar")
data = response.json()
assert data == {"some_arg": "foo", "q": "bar"}