Skip to content

Commit bbe4002

Browse files
committed
test: fix tests for pydantic 1.10.0
1 parent 6159e90 commit bbe4002

File tree

7 files changed

+207
-28
lines changed

7 files changed

+207
-28
lines changed

poetry.lock

Lines changed: 89 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ uvicorn = "^0.14.0"
2222
rst_include = "^2.1.0"
2323
pytest = "^6.2"
2424
sentry-sdk = "^1.3.0"
25+
requests = ">0.0.0"
2526

2627
[build-system]
2728
requires = ["poetry>=0.12"]

tests/conftest.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import platform
33
from json import dumps as json_dumps
44

5+
import packaging.version
6+
import pydantic
57
import pytest
68
from _pytest.python_api import RaisesContext
79
from starlette.testclient import TestClient
@@ -123,3 +125,19 @@ def requester(method, params, request_id=0):
123125
'params': params,
124126
}, path_postfix=path_postfix)
125127
return requester
128+
129+
130+
@pytest.fixture
131+
def openapi_compatible():
132+
if packaging.version.parse(pydantic.VERSION) >= packaging.version.parse("1.10.0"):
133+
def _openapi_compatible(value: dict):
134+
return value
135+
else:
136+
def _openapi_compatible(obj: dict):
137+
for k, v in obj.items():
138+
if isinstance(v, dict):
139+
obj[k] = _openapi_compatible(obj[k])
140+
if 'const' in obj and 'default' in obj:
141+
del obj['default']
142+
return obj
143+
return _openapi_compatible

0 commit comments

Comments
 (0)