File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed
tests/functional/event_handler/_pydantic Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -2678,20 +2678,21 @@ def test_parse_form_data_exception(monkeypatch):
26782678 """Test that _parse_form_data raises RequestValidationError on exception"""
26792679 import pytest
26802680 from aws_lambda_powertools .event_handler .middlewares .openapi_validation import OpenAPIRequestValidationMiddleware
2681+ from aws_lambda_powertools .event_handler .openapi .exceptions import RequestValidationError
26812682 class DummyEvent :
26822683 decoded_body = None
26832684 class DummyApp :
26842685 current_event = DummyEvent ()
26852686 # Correct monkeypatch: replace parse_qs with a function that raises Exception
26862687 def _raise (* a , ** kw ):
2687- raise Exception ("fail" )
2688+ raise ValueError ("fail" )
26882689
26892690 monkeypatch .setattr (
26902691 "aws_lambda_powertools.event_handler.middlewares.openapi_validation.parse_qs" ,
26912692 _raise ,
26922693 )
26932694 middleware = OpenAPIRequestValidationMiddleware ()
2694- with pytest .raises (Exception ) as excinfo :
2695+ with pytest .raises (RequestValidationError ) as excinfo :
26952696 middleware ._parse_form_data (DummyApp ())
26962697 assert "Form data parsing error" in str (excinfo .value )
26972698 assert "fail" in str (excinfo .value )
You can’t perform that action at this time.
0 commit comments