Coverage for tests / test_callable_endpoint.py: 100%

14 statements  

« prev     ^ index     » next       coverage.py v7.13.3, created at 2026-02-12 18:15 +0000

1from functools import partial 1abcd

2from typing import Optional 1abcd

3 

4from fastapi import FastAPI 1abcd

5from fastapi.testclient import TestClient 1abcd

6 

7 

8def main(some_arg, q: Optional[str] = None): 1abcd

9 return {"some_arg": some_arg, "q": q} 1efg

10 

11 

12endpoint = partial(main, "foo") 1abcd

13 

14app = FastAPI() 1abcd

15 

16app.get("/")(endpoint) 1abcd

17 

18 

19client = TestClient(app) 1abcd

20 

21 

22def test_partial(): 1abcd

23 response = client.get("/?q=bar") 1efg

24 data = response.json() 1efg

25 assert data == {"some_arg": "foo", "q": "bar"} 1efg