Skip to content

Commit

Permalink
converters(test): add import logic
Browse files Browse the repository at this point in the history
  • Loading branch information
gmcrocetti committed Aug 11, 2020
1 parent 5ec9dfc commit 74ffbcb
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions tests/unit/test_converters.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
# Standard library imports
import typing
import sys

# Third-party imports
import marshmallow
import pydantic

try:
import pydantic
except ImportError:
if sys.version_info >= (3, 6):
raise

import pytest

# Local imports
Expand Down Expand Up @@ -451,18 +458,19 @@ def test_dict_converter(self):
assert output == "1"


@pytest.fixture
def pydantic_model_mock(mocker):
class Model(pydantic.BaseModel):
def __new__(cls, *args, **kwargs):
return model

model = mocker.Mock(spec=Model)

return model, Model
@pytest.mark.skipif(
sys.version_info < (3, 6), reason="requires python3.6 or higher"
)
class TestPydanticConverter(object):
@pytest.fixture
def pydantic_model_mock(self, mocker):
class Model(pydantic.BaseModel):
def __new__(cls, *args, **kwargs):
return model

model = mocker.Mock(spec=Model)
return model, Model

class TestPydanticConverter(object):
def test_init_without_pydantic(self, mocker):
mocker.patch.object(
converters.PydanticConverter,
Expand Down

0 comments on commit 74ffbcb

Please sign in to comment.