Fixed route dispatch handling for aiohttp HTTP exceptions.
CI / Formatting (push) Successful in 5s
CI / Linting (push) Successful in 5s
CI / Tests (Python 3.12) (push) Successful in 2m48s
CI / Tests (Python 3.13) (push) Successful in 2m53s
CI / Tests (Python 3.14) (push) Successful in 2m43s
CI / Type Checking (push) Successful in 9s
CI / Spelling (push) Successful in 5s
CI / Formatting (push) Successful in 5s
CI / Linting (push) Successful in 5s
CI / Tests (Python 3.12) (push) Successful in 2m48s
CI / Tests (Python 3.13) (push) Successful in 2m53s
CI / Tests (Python 3.14) (push) Successful in 2m43s
CI / Type Checking (push) Successful in 9s
CI / Spelling (push) Successful in 5s
This commit is contained in:
@@ -659,8 +659,8 @@ class RouteDispatcher:
|
|||||||
type(result).__name__,
|
type(result).__name__,
|
||||||
)
|
)
|
||||||
return web.Response(status=500)
|
return web.Response(status=500)
|
||||||
except web.HTTPException as exc:
|
except web.HTTPException:
|
||||||
return exc
|
raise
|
||||||
except TimeoutError:
|
except TimeoutError:
|
||||||
mod_logger.warning(
|
mod_logger.warning(
|
||||||
"Route handler '%s' timed out after %ss.",
|
"Route handler '%s' timed out after %ss.",
|
||||||
|
|||||||
@@ -898,7 +898,7 @@ class TestRouteDispatcherDispatch:
|
|||||||
self,
|
self,
|
||||||
module_context: ModuleContext,
|
module_context: ModuleContext,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Raised aiohttp HTTP exceptions are passed through."""
|
"""Raised aiohttp HTTP exceptions are re-raised for aiohttp to handle."""
|
||||||
exc = web.HTTPFound("/dest")
|
exc = web.HTTPFound("/dest")
|
||||||
|
|
||||||
async def handler(ctx: RouteContext) -> web.Response:
|
async def handler(ctx: RouteContext) -> web.Response:
|
||||||
@@ -911,8 +911,9 @@ class TestRouteDispatcherDispatch:
|
|||||||
request.match_info["module_name"] = "mod"
|
request.match_info["module_name"] = "mod"
|
||||||
request.match_info["path"] = "page"
|
request.match_info["path"] = "page"
|
||||||
|
|
||||||
response = await dispatcher.dispatch(request)
|
with pytest.raises(web.HTTPFound) as exc_info:
|
||||||
assert response is exc
|
await dispatcher.dispatch(request)
|
||||||
|
assert exc_info.value is exc
|
||||||
|
|
||||||
async def test_dispatch_none_response(self, module_context: ModuleContext) -> None:
|
async def test_dispatch_none_response(self, module_context: ModuleContext) -> None:
|
||||||
"""Handler returning None produces 204 No Content."""
|
"""Handler returning None produces 204 No Content."""
|
||||||
|
|||||||
Reference in New Issue
Block a user