Get rid of unused exceptions

This commit is contained in:
p1c2u 2021-05-02 20:24:07 +01:00
parent 9b2a4d8147
commit bbeb43c300
3 changed files with 1 additions and 32 deletions

View file

@ -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

View file

@ -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:

View file

@ -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])