diff --git a/src/quart_schema/validation.py b/src/quart_schema/validation.py index 2f1a37d..c18c106 100644 --- a/src/quart_schema/validation.py +++ b/src/quart_schema/validation.py @@ -223,7 +223,7 @@ async def wrapper(*args: Any, **kwargs: Any) -> Any: if isinstance(value, (Response, WerkzeugResponse)): if status == status_code: - raise ResponseHeadersValidationError() + raise RuntimeError("Cannot validate Response instance") else: return result diff --git a/tests/test_validation.py b/tests/test_validation.py index 5a32ca3..a201911 100644 --- a/tests/test_validation.py +++ b/tests/test_validation.py @@ -211,6 +211,20 @@ async def item() -> ResponseReturnValue: assert response.status_code == 302 +async def test_response_validation_of_response() -> None: + app = Quart(__name__) + QuartSchema(app) + + @app.route("/") + @validate_response(PyItem) + async def item() -> ResponseReturnValue: + return Response(200) + + test_client = app.test_client() + response = await test_client.get("/") + assert response.status_code == 500 + + @pytest.mark.parametrize( "return_value, status", [