Skip to content

Commit

Permalink
mark hypothesis as thread unsafe
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt committed Feb 6, 2025
1 parent b8e1006 commit 7845004
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ filterwarnings = [
# Python 3.9 and below allowed truncation of float to integers in some
# cases, by not making this an error we can test for this behaviour
'ignore:(.+)Implicit conversion to integers using __int__ is deprecated',
# free-threading seems to upset Hypothesis
'ignore:(.*)The recursion limit will not be reset, since it was changed from another thread or during execution of a test.(.*)',
'ignore:(.*)Do not use the `random` module inside strategies(.*)',
]
timeout = 30
xfail_strict = true
Expand Down
8 changes: 8 additions & 0 deletions tests/test_hypothesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def test_datetime_datetime(datetime_schema, data):

@pytest.mark.skipif(sys.platform == 'win32', reason='Can fail on windows, I guess due to 64-bit issue')
@given(strategies.integers(min_value=-11_676_096_000, max_value=253_402_300_799_000))
@pytest.mark.thread_unsafe # https://github.com/Quansight-Labs/pytest-run-parallel/issues/20
def test_datetime_int(datetime_schema, data):
try:
if abs(data) > 20_000_000_000:
Expand All @@ -41,6 +42,7 @@ def test_datetime_int(datetime_schema, data):


@given(strategies.binary())
@pytest.mark.thread_unsafe # https://github.com/Quansight-Labs/pytest-run-parallel/issues/20
def test_datetime_binary(datetime_schema, data):
try:
datetime_schema.validate_python(data)
Expand Down Expand Up @@ -89,6 +91,7 @@ class BranchModel(TypedDict):

@pytest.mark.skipif(sys.platform == 'emscripten', reason='Seems to fail sometimes on pyodide no idea why')
@given(strategies.from_type(BranchModel))
@pytest.mark.thread_unsafe # https://github.com/Quansight-Labs/pytest-run-parallel/issues/20
def test_recursive(definition_schema, data):
assert definition_schema.validate_python(data) == data

Expand All @@ -108,6 +111,7 @@ def branch_models_with_cycles(draw, existing=None):


@given(branch_models_with_cycles())
@pytest.mark.thread_unsafe # https://github.com/Quansight-Labs/pytest-run-parallel/issues/20
def test_definition_cycles(definition_schema, data):
try:
assert definition_schema.validate_python(data) == data
Expand All @@ -130,6 +134,7 @@ def test_definition_broken(definition_schema):


@given(strategies.timedeltas())
@pytest.mark.thread_unsafe # https://github.com/Quansight-Labs/pytest-run-parallel/issues/20
def test_pytimedelta_as_timedelta(dt):
v = SchemaValidator({'type': 'timedelta', 'gt': dt})
# simplest way to check `pytimedelta_as_timedelta` is correct is to extract duration from repr of the validator
Expand All @@ -150,6 +155,7 @@ def url_validator():


@given(strategies.text())
@pytest.mark.thread_unsafe # https://github.com/Quansight-Labs/pytest-run-parallel/issues/20
def test_urls_text(url_validator, text):
try:
url_validator.validate_python(text)
Expand All @@ -166,6 +172,7 @@ def multi_host_url_validator():


@given(strategies.text())
@pytest.mark.thread_unsafe # https://github.com/Quansight-Labs/pytest-run-parallel/issues/20
def test_multi_host_urls_text(multi_host_url_validator, text):
try:
multi_host_url_validator.validate_python(text)
Expand All @@ -182,6 +189,7 @@ def str_serializer():


@given(strategies.text())
@pytest.mark.thread_unsafe # https://github.com/Quansight-Labs/pytest-run-parallel/issues/20
def test_serialize_string(str_serializer: SchemaSerializer, data):
assert str_serializer.to_python(data) == data
assert json.loads(str_serializer.to_json(data)) == data

0 comments on commit 7845004

Please sign in to comment.