Coverage for tests/test_callable_endpoint.py: 100%

14 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-12-04 08:29 +0000

1from functools import partial 1abcdefg

2from typing import Optional 1abcdefg

3 

4from fastapi import FastAPI 1abcdefg

5from fastapi.testclient import TestClient 1abcdefg

6 

7 

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

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

10 

11 

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

13 

14app = FastAPI() 1abcdefg

15 

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

17 

18 

19client = TestClient(app) 1abcdefg

20 

21 

22def test_partial(): 1abcdefg

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

24 data = response.json() 1hijklmn

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