Coverage for tests/test_operations_signatures.py: 100%
17 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
1import inspect 1ghijkl
3from fastapi import APIRouter, FastAPI 1ghijkl
5method_names = ["get", "put", "post", "delete", "options", "head", "patch", "trace"] 1ghijkl
8def test_signatures_consistency(): 1ghijkl
9 base_sig = inspect.signature(APIRouter.get) 1abcdef
10 for method_name in method_names: 1abcdef
11 router_method = getattr(APIRouter, method_name) 1abcdef
12 app_method = getattr(FastAPI, method_name) 1abcdef
13 router_sig = inspect.signature(router_method) 1abcdef
14 app_sig = inspect.signature(app_method) 1abcdef
15 param: inspect.Parameter
16 for key, param in base_sig.parameters.items(): 1abcdef
17 router_param: inspect.Parameter = router_sig.parameters[key] 1abcdef
18 app_param: inspect.Parameter = app_sig.parameters[key] 1abcdef
19 assert param.annotation == router_param.annotation 1abcdef
20 assert param.annotation == app_param.annotation 1abcdef
21 assert param.default == router_param.default 1abcdef
22 assert param.default == app_param.default 1abcdef