Issue Manager / issue-manager (push) Has been cancelled
Build Docs / changes (push) Has been cancelled
Build Docs / langs (push) Has been cancelled
Build Docs / build-docs (push) Has been cancelled
Build Docs / docs-all-green (push) Has been cancelled
Conflict detector / main (push) Has been cancelled
Test Redistribute / test-redistribute (fastapi) (push) Has been cancelled
Test Redistribute / test-redistribute (fastapi-slim) (push) Has been cancelled
Test Redistribute / test-redistribute-alls-green (push) Has been cancelled
Test / lint (push) Has been cancelled
Test / test (pydantic-v1, 3.10) (push) Has been cancelled
Test / test (pydantic-v1, 3.11) (push) Has been cancelled
Test / test (pydantic-v1, 3.13) (push) Has been cancelled
Test / test (pydantic-v1, 3.8) (push) Has been cancelled
Test / test (pydantic-v1, 3.9) (push) Has been cancelled
Test / test (pydantic-v2, 3.10) (push) Has been cancelled
Test / test (pydantic-v2, 3.11) (push) Has been cancelled
Test / test (pydantic-v2, 3.12) (push) Has been cancelled
Test / test (pydantic-v2, 3.13) (push) Has been cancelled
Test / test (pydantic-v2, 3.14) (push) Has been cancelled
Test / test (pydantic-v2, 3.8) (push) Has been cancelled
Test / test (pydantic-v2, 3.9) (push) Has been cancelled
Test / coverage-combine (push) Has been cancelled
Test / check (push) Has been cancelled
Label Approved / label-approved (push) Has been cancelled
FastAPI People Contributors / job (push) Has been cancelled
FastAPI People Sponsors / job (push) Has been cancelled
Update Topic Repos / topic-repos (push) Has been cancelled
FastAPI People / job (push) Has been cancelled
Test / test (pydantic-v1, 3.12) (push) Has been cancelled
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
|