mirror of
https://github.com/fastapi/fastapi.git
synced 2026-01-05 04:30:26 -05:00
* ✨ Make jsonable_encoder's include and exclude receive sequences * ✨ Add include, exclude, and by_alias to app and router * ✨ Add and update tutorial code with new parameters * 📝 Update docs for new parameters and add docs for updating data * ✅ Add tests for consistency in path operation methods * ✅ Add tests for new parameters and update tests
23 lines
934 B
Python
23 lines
934 B
Python
import inspect
|
|
|
|
from fastapi import APIRouter, FastAPI
|
|
|
|
method_names = ["get", "put", "post", "delete", "options", "head", "patch", "trace"]
|
|
|
|
|
|
def test_signatures_consistency():
|
|
base_sig = inspect.signature(APIRouter.get)
|
|
for method_name in method_names:
|
|
router_method = getattr(APIRouter, method_name)
|
|
app_method = getattr(FastAPI, method_name)
|
|
router_sig = inspect.signature(router_method)
|
|
app_sig = inspect.signature(app_method)
|
|
param: inspect.Parameter
|
|
for key, param in base_sig.parameters.items():
|
|
router_param: inspect.Parameter = router_sig.parameters[key]
|
|
app_param: inspect.Parameter = app_sig.parameters[key]
|
|
assert param.annotation == router_param.annotation
|
|
assert param.annotation == app_param.annotation
|
|
assert param.default == router_param.default
|
|
assert param.default == app_param.default
|