diff --git a/requirements-test.txt b/requirements-test.txt --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,4 +1,4 @@ -hypothesis >= 3.11.0, < 6 +hypothesis >= 3.11.0 pytest pytest-mock sqlalchemy-stubs diff --git a/swh/storage/tests/algos/test_snapshot.py b/swh/storage/tests/algos/test_snapshot.py --- a/swh/storage/tests/algos/test_snapshot.py +++ b/swh/storage/tests/algos/test_snapshot.py @@ -3,7 +3,7 @@ # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information -from hypothesis import given +from hypothesis import given, settings import pytest from swh.model.hypothesis_strategies import branch_names, branch_targets, snapshots @@ -21,6 +21,7 @@ snapshot_resolve_alias, visits_and_snapshots_get_from_revision, ) +from swh.storage.tests.conftest import function_scoped_fixture_check from swh.storage.utils import now @@ -32,6 +33,7 @@ } +@settings(suppress_health_check=function_scoped_fixture_check) @given(snapshot=snapshots(min_size=0, max_size=10, only_objects=False)) def test_snapshot_small(swh_storage, snapshot): # noqa swh_storage.snapshot_add([snapshot]) @@ -40,6 +42,7 @@ assert snapshot == returned_snapshot +@settings(suppress_health_check=function_scoped_fixture_check) @given(branch_name=branch_names(), branch_target=branch_targets(only_objects=True)) def test_snapshot_large(swh_storage, branch_name, branch_target): # noqa snapshot = Snapshot( diff --git a/swh/storage/tests/conftest.py b/swh/storage/tests/conftest.py --- a/swh/storage/tests/conftest.py +++ b/swh/storage/tests/conftest.py @@ -5,6 +5,8 @@ import multiprocessing.util +from hypothesis import HealthCheck +from hypothesis import __version_info__ as hypothesis_version from hypothesis import settings import pytest @@ -19,6 +21,12 @@ from swh.model.tests.generate_testdata import gen_contents, gen_origins from swh.storage.interface import StorageInterface +function_scoped_fixture_check = ( + [HealthCheck.function_scoped_fixture] # type: ignore + if hypothesis_version >= (5, 49) + else [] +) + # define tests profile. Full documentation is at: # https://hypothesis.readthedocs.io/en/latest/settings.html#settings-profiles settings.register_profile("fast", max_examples=5, deadline=5000) diff --git a/swh/storage/tests/storage_tests.py b/swh/storage/tests/storage_tests.py --- a/swh/storage/tests/storage_tests.py +++ b/swh/storage/tests/storage_tests.py @@ -36,6 +36,7 @@ from swh.storage.common import origin_url_to_sha1 as sha1 from swh.storage.exc import HashCollision, StorageArgumentException from swh.storage.interface import ListOrder, PagedResult, StorageInterface +from swh.storage.tests.conftest import function_scoped_fixture_check from swh.storage.utils import ( content_hex_hashes, now, @@ -424,7 +425,10 @@ assert missing == [cont2.hashes()] @pytest.mark.property_based - @settings(deadline=None) # this test is very slow + @settings( + deadline=None, # this test is very slow + suppress_health_check=function_scoped_fixture_check, + ) @given( strategies.sets( elements=strategies.sampled_from(["sha256", "sha1_git", "blake2s256"]), @@ -455,6 +459,7 @@ ) == set(missing_per_hash[hash]) @pytest.mark.property_based + @settings(suppress_health_check=function_scoped_fixture_check,) @given( strategies.sets( elements=strategies.sampled_from(["sha256", "sha1_git", "blake2s256"]), @@ -3951,7 +3956,9 @@ ) assert swh_storage.origin_count("github", regexp=True, with_visit=True) == 1 - @settings(suppress_health_check=[HealthCheck.too_slow]) + @settings( + suppress_health_check=[HealthCheck.too_slow] + function_scoped_fixture_check, + ) @given(strategies.lists(objects(split_content=True), max_size=2)) def test_add_arbitrary(self, swh_storage, objects): for (obj_type, obj) in objects: