mirror of
https://github.com/fastapi/fastapi.git
synced 2026-02-19 23:44:51 -05:00
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>
25 lines
426 B
Python
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"}
|