-
-
Notifications
You must be signed in to change notification settings - Fork 136
Expand file tree
/
Copy pathtest_exceptions.py
More file actions
27 lines (22 loc) · 774 Bytes
/
test_exceptions.py
File metadata and controls
27 lines (22 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from openapi_core.schema.schemas import exceptions
import pytest
import attr
def is_open_api_exception(exception_type):
try:
return issubclass(exception_type, exceptions.OpenAPISchemaError)
except TypeError:
return False
class TestExceptions:
@pytest.mark.parametrize(
"exception_type",
(
exception_type
for exception_type_name in dir(exceptions)
for exception_type in [getattr(exceptions, exception_type_name)]
if is_open_api_exception(exception_type)
)
)
def test_convert_to_string(self, exception_type):
# verify that we can convert to a string without error
args = ['x'] * len(attr.fields(exception_type))
str(exception_type(*args))