Skip to content
Snippets Groups Projects
Commit 76360cc7 authored by Antoine Lambert's avatar Antoine Lambert
Browse files

tests: Drop hypothesis < 6 requirement

Ensure tests can be executed using hypothesis >= 6 by suppressing
the function_scoped_fixture health check on test that uses a function
scope fixture in combination with @given that does not need to be reset
between individual hypothesis examples.
parent 576b1047
No related branches found
No related tags found
1 merge request!207tests: Drop hypothesis < 6 requirement
pytest
pytest-mock
requests-mock
hypothesis >= 3.11.0, < 6
hypothesis >= 3.11.0
pre-commit
pytz
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 []
)
......@@ -12,7 +12,7 @@ from typing import Any
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 typing_extensions import Protocol
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 @@ def test_db_copy_to_static(db_with_data):
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]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment