mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
make hypothesis optional for testing (#2343)
* make hypothesis optional for testing * fix coveragin in "_hypothesis_plugin.py" * uncomment ci checks
This commit is contained in:
@@ -59,7 +59,7 @@ else:
|
||||
try:
|
||||
email_validator.validate_email(s, check_deliverability=False)
|
||||
return True
|
||||
except email_validator.EmailNotValidError:
|
||||
except email_validator.EmailNotValidError: # pragma: no cover
|
||||
return False
|
||||
|
||||
# Note that these strategies deliberately stay away from any tricky Unicode
|
||||
@@ -217,7 +217,7 @@ def resolves(
|
||||
def resolve_json(cls): # type: ignore[no-untyped-def]
|
||||
try:
|
||||
inner = st.none() if cls.inner_type is None else st.from_type(cls.inner_type)
|
||||
except Exception:
|
||||
except Exception: # pragma: no cover
|
||||
finite = st.floats(allow_infinity=False, allow_nan=False)
|
||||
inner = st.recursive(
|
||||
base=st.one_of(st.none(), st.booleans(), st.integers(), finite, st.text()),
|
||||
|
||||
+6
-1
@@ -10,7 +10,12 @@ import pytest
|
||||
from _pytest.assertion.rewrite import AssertionRewritingHook
|
||||
|
||||
# See https://hypothesis.readthedocs.io/en/latest/strategies.html#interaction-with-pytest-cov
|
||||
pytest_plugins = ['hypothesis.extra.pytestplugin']
|
||||
try:
|
||||
import hypothesis # noqa
|
||||
except ImportError:
|
||||
pytest_plugins = []
|
||||
else:
|
||||
pytest_plugins = ['hypothesis.extra.pytestplugin']
|
||||
|
||||
|
||||
def _extract_source_code_from_function(function):
|
||||
|
||||
@@ -1,11 +1,21 @@
|
||||
import typing
|
||||
|
||||
import pytest
|
||||
from hypothesis import given, strategies as st
|
||||
|
||||
import pydantic
|
||||
from pydantic.networks import import_email_validator
|
||||
|
||||
try:
|
||||
from hypothesis import given, strategies as st
|
||||
except ImportError:
|
||||
|
||||
def given(*args, **kwargs):
|
||||
return lambda f: f
|
||||
|
||||
st = type('st', (), {'data': lambda: None})
|
||||
|
||||
pytestmark = pytest.mark.skipif(True, reason='"hypothesis" not installed')
|
||||
|
||||
|
||||
def gen_models():
|
||||
class MiscModel(pydantic.BaseModel):
|
||||
|
||||
Reference in New Issue
Block a user