diff --git a/requirements-test.txt b/requirements-test.txt --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,6 +1,6 @@ pytest pytest-mock requests-mock -hypothesis >= 3.11.0, < 6 +hypothesis >= 3.11.0 pre-commit pytz diff --git a/swh/core/db/tests/conftest.py b/swh/core/db/tests/conftest.py --- a/swh/core/db/tests/conftest.py +++ b/swh/core/db/tests/conftest.py @@ -1,3 +1,12 @@ import os +from hypothesis import HealthCheck + os.environ["LC_ALL"] = "C.UTF-8" + +# we use getattr here to keep mypy happy regardless hypothesis version +function_scoped_fixture_check = ( + [getattr(HealthCheck, "function_scoped_fixture")] + if hasattr(HealthCheck, "function_scoped_fixture") + else [] +) diff --git a/swh/core/db/tests/test_db.py b/swh/core/db/tests/test_db.py --- a/swh/core/db/tests/test_db.py +++ b/swh/core/db/tests/test_db.py @@ -12,7 +12,7 @@ from unittest.mock import MagicMock, Mock import uuid -from hypothesis import given, strategies +from hypothesis import given, settings, strategies from hypothesis.extra.pytz import timezones import psycopg2 import pytest @@ -21,6 +21,7 @@ from swh.core.db import BaseDb from swh.core.db.common import db_transaction, db_transaction_generator from swh.core.db.pytest_plugin import postgresql_fact +from swh.core.db.tests.conftest import function_scoped_fixture_check # workaround mypy bug https://github.com/python/mypy/issues/5485 @@ -282,6 +283,7 @@ assert EXPECTED_ROW_OUT == output[0] +@settings(suppress_health_check=function_scoped_fixture_check) @given(db_rows) def test_db_copy_to(db_with_data, data): items = [dict(zip(COLUMNS, item)) for item in data]