From 6551788dc0c48660fe98ae23ca6c3b73d31f7b67 Mon Sep 17 00:00:00 2001 From: rajratanm Date: Tue, 24 Mar 2026 17:42:58 +0530 Subject: [PATCH] Cover legacy handler path in routing facade tests. Exercise get_request_handler legacy dependant signature and execute raw response helper to close remaining uncovered lines seen in coverage-combine. Made-with: Cursor --- tests/test_routing_facade_contract.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/test_routing_facade_contract.py b/tests/test_routing_facade_contract.py index 8dbcc868b2..256ac524a3 100644 --- a/tests/test_routing_facade_contract.py +++ b/tests/test_routing_facade_contract.py @@ -1,7 +1,8 @@ from enum import IntEnum import fastapi.routing as routing -from fastapi.routing_handlers import RouteHandlerConfig +from fastapi.dependencies.utils import get_dependant +from fastapi.routing_handlers import RouteHandlerConfig, get_request_handler from fastapi.routing_router import APIRouter from fastapi.routing_routes import APIRoute, APIWebSocketRoute from fastapi.routing_utils import request_response, websocket_session @@ -50,6 +51,9 @@ def _raw_response_endpoint() -> Response: def test_api_route_defaults_and_intenum_status_paths() -> None: + raw = _raw_response_endpoint() + assert raw.body == b"ok" + route = routing.APIRoute( "/raw-response", _raw_response_endpoint, @@ -60,6 +64,15 @@ def test_api_route_defaults_and_intenum_status_paths() -> None: assert route.methods == {"GET"} +def test_get_request_handler_supports_legacy_dependant_signature() -> None: + async def endpoint() -> dict[str, str]: + return {"ok": "true"} + + dependant = get_dependant(path="/legacy", call=endpoint) + handler = get_request_handler(dependant) + assert callable(handler) + + def test_request_response_wraps_sync_callable() -> None: def endpoint(_: Request) -> Response: return Response("sync-ok")