Coverage for tests/test_callable_endpoint.py: 100%
14 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-05-05 00:03 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-05-05 00:03 +0000
1from functools import partial 1abcdef
2from typing import Optional 1abcdef
4from fastapi import FastAPI 1abcdef
5from fastapi.testclient import TestClient 1abcdef
8def main(some_arg, q: Optional[str] = None): 1abcdef
9 return {"some_arg": some_arg, "q": q} 1ghijkl
12endpoint = partial(main, "foo") 1abcdef
14app = FastAPI() 1abcdef
16app.get("/")(endpoint) 1abcdef
19client = TestClient(app) 1abcdef
22def test_partial(): 1abcdef
23 response = client.get("/?q=bar") 1ghijkl
24 data = response.json() 1ghijkl
25 assert data == {"some_arg": "foo", "q": "bar"} 1ghijkl