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