From bbeb43c300228f51f73392dab33c210fa56f1532 Mon Sep 17 00:00:00 2001 From: p1c2u Date: Sun, 2 May 2021 20:24:07 +0100 Subject: [PATCH] Get rid of unused exceptions --- openapi_core/exceptions.py | 17 ----------------- openapi_core/validation/request/shortcuts.py | 11 ----------- tests/unit/unmarshalling/test_validate.py | 5 +---- 3 files changed, 1 insertion(+), 32 deletions(-) diff --git a/openapi_core/exceptions.py b/openapi_core/exceptions.py index 6ce0572..0d33884 100644 --- a/openapi_core/exceptions.py +++ b/openapi_core/exceptions.py @@ -6,19 +6,6 @@ class OpenAPIError(Exception): pass -class OpenAPIMediaTypeError(OpenAPIError): - pass - - -@attr.s(hash=True) -class InvalidContentType(OpenAPIMediaTypeError): - mimetype = attr.ib() - - def __str__(self): - return "Content for following mimetype not found: {0}".format( - self.mimetype) - - class OpenAPIParameterError(OpenAPIError): pass @@ -67,7 +54,3 @@ class MissingResponseContent(OpenAPIResponseError): def __str__(self): return "Missing response content" - - -class OpenAPISchemaError(OpenAPIError): - pass diff --git a/openapi_core/validation/request/shortcuts.py b/openapi_core/validation/request/shortcuts.py index 55e2c9e..8539f9d 100644 --- a/openapi_core/validation/request/shortcuts.py +++ b/openapi_core/validation/request/shortcuts.py @@ -1,19 +1,8 @@ """OpenAPI core validation request shortcuts module""" import warnings -from openapi_core.exceptions import ( - OpenAPIMediaTypeError, OpenAPIParameterError, OpenAPIRequestBodyError, - OpenAPISchemaError, -) from openapi_core.validation.request.validators import RequestValidator -ERRORS_BODY = ( - OpenAPIRequestBodyError, OpenAPIMediaTypeError, OpenAPISchemaError, -) -ERRORS_PARAMETERS = ( - OpenAPIParameterError, -) - def validate_request(validator, request, failsafe=None): if failsafe is None: diff --git a/tests/unit/unmarshalling/test_validate.py b/tests/unit/unmarshalling/test_validate.py index 8dad170..b73c341 100644 --- a/tests/unit/unmarshalling/test_validate.py +++ b/tests/unit/unmarshalling/test_validate.py @@ -4,7 +4,6 @@ import mock import pytest from openapi_core.extensions.models.models import Model -from openapi_core.exceptions import OpenAPISchemaError from openapi_core.spec.paths import SpecPath from openapi_core.unmarshalling.schemas.factories import ( SchemaUnmarshallersFactory, @@ -55,8 +54,6 @@ class TestSchemaValidate(object): assert result is None - @pytest.mark.xfail( - reason="validation does not care about custom formats atm") def test_string_format_custom_missing(self, validator_factory): custom_format = 'custom' spec = { @@ -66,7 +63,7 @@ class TestSchemaValidate(object): schema = SpecPath.from_spec(spec) value = 'x' - with pytest.raises(OpenAPISchemaError): + with pytest.raises(FormatterNotFoundError): validator_factory(schema).validate(value) @pytest.mark.parametrize('value', [False, True])