Skip to content

Commit 7cc8d25

Browse files
authored
disable hypothesis health check to avoid false negative (pydantic#2389)
1 parent ce67660 commit 7cc8d25

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
# See https://hypothesis.readthedocs.io/en/latest/strategies.html#interaction-with-pytest-cov
1313
try:
14-
import hypothesis # noqa
14+
from hypothesis import given # noqa
1515
except ImportError:
1616
pytest_plugins = []
1717
else:

tests/test_hypothesis_plugin.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
from pydantic.networks import import_email_validator
77

88
try:
9-
from hypothesis import given, strategies as st
9+
from hypothesis import HealthCheck, given, settings, strategies as st
1010
except ImportError:
11+
from unittest import mock
1112

12-
def given(*args, **kwargs):
13-
return lambda f: f
14-
15-
st = type('st', (), {'data': lambda: None})
13+
given = settings = lambda *a, **kw: (lambda f: f) # pass-through decorator
14+
HealthCheck = st = mock.Mock()
1615

1716
pytestmark = pytest.mark.skipif(True, reason='"hypothesis" not installed')
1817

@@ -105,6 +104,7 @@ class EmailsModel(pydantic.BaseModel):
105104

106105

107106
@pytest.mark.parametrize('model', gen_models())
107+
@settings(suppress_health_check={HealthCheck.too_slow})
108108
@given(data=st.data())
109109
def test_can_construct_models_with_all_fields(data, model):
110110
# The value of this test is to confirm that Hypothesis knows how to provide

0 commit comments

Comments
 (0)