1212import yarl
1313
1414from aiopenapi3 import OpenAPI
15- from aiopenapi3 .errors import OperationParameterValidationError , OperationIdDuplicationError , HeadersMissingError
15+ from aiopenapi3 .errors import (
16+ OperationParameterValidationError ,
17+ OperationIdDuplicationError ,
18+ HeadersMissingError ,
19+ HttpClientError ,
20+ HttpServerError ,
21+ )
1622
1723URLBASE = "/"
1824
@@ -480,7 +486,7 @@ def test_paths_tags(httpx_mock, with_paths_tags):
480486
481487
482488def test_paths_response_status_pattern_default (httpx_mock , with_paths_response_status_pattern_default ):
483- api = OpenAPI ("/" , with_paths_response_status_pattern_default , session_factory = httpx .Client )
489+ api = OpenAPI ("/" , with_paths_response_status_pattern_default , session_factory = httpx .Client , raise_on_error = False )
484490
485491 httpx_mock .add_response (headers = {"Content-Type" : "application/json" }, status_code = 201 , json = "created" )
486492 r = api ._ .test ()
@@ -505,10 +511,10 @@ def test_paths_response_status_pattern_default(httpx_mock, with_paths_response_s
505511 api ._ .test ()
506512
507513
508- def test_paths_response_error (httpx_mock , with_paths_response_error ):
514+ def test_paths_response_error (httpx_mock , with_paths_response_error_vXX ):
509515 from aiopenapi3 import ResponseSchemaError , ContentTypeError , HTTPStatusError , ResponseDecodingError
510516
511- api = OpenAPI ("/" , with_paths_response_error , session_factory = httpx .Client )
517+ api = OpenAPI ("/" , with_paths_response_error_vXX , session_factory = httpx .Client )
512518
513519 httpx_mock .add_response (headers = {"Content-Type" : "application/json" }, status_code = 200 , json = "ok" )
514520 r = api ._ .test ()
@@ -530,6 +536,18 @@ def test_paths_response_error(httpx_mock, with_paths_response_error):
530536 with pytest .raises (ResponseSchemaError ):
531537 api ._ .test ()
532538
539+ httpx_mock .add_response (headers = {"Content-Type" : "application/json" , "X-required" : "1" }, status_code = 437 , json = "ok" )
540+ with pytest .raises (HttpClientError ):
541+ api ._ .test ()
542+
543+ httpx_mock .add_response (headers = {"Content-Type" : "application/json" , "X-required" : "1" }, status_code = 537 , json = "ok" )
544+ with pytest .raises (HttpServerError ):
545+ api ._ .test ()
546+
547+ httpx_mock .add_response (headers = {"Content-Type" : "application/json" , "X-required" : "1" }, status_code = 437 , json = "ok" )
548+ api ._raise_on_error = False
549+ api ._ .test ()
550+
533551
534552@pytest .mark .httpx_mock (can_send_already_matched_responses = True )
535553def test_paths_request_calling (httpx_mock , with_paths_response_status_pattern_default ):
0 commit comments