Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/tests/conftest.py
# Copyright (C) 2019-2020 The Software Heritage developers | # Copyright (C) 2019-2020 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import multiprocessing.util | import multiprocessing.util | ||||
from hypothesis import settings | from hypothesis import HealthCheck, settings | ||||
import pytest | import pytest | ||||
try: | try: | ||||
import pytest_cov.embed | import pytest_cov.embed | ||||
except ImportError: | except ImportError: | ||||
pytest_cov = None | pytest_cov = None | ||||
from typing import Iterable | from typing import Iterable | ||||
from swh.model.model import BaseContent, Origin | from swh.model.model import BaseContent, Origin | ||||
from swh.model.tests.generate_testdata import gen_contents, gen_origins | from swh.model.tests.generate_testdata import gen_contents, gen_origins | ||||
from swh.storage.interface import StorageInterface | from swh.storage.interface import StorageInterface | ||||
# 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 [] | |||||
) | |||||
# define tests profile. Full documentation is at: | # define tests profile. Full documentation is at: | ||||
# https://hypothesis.readthedocs.io/en/latest/settings.html#settings-profiles | # https://hypothesis.readthedocs.io/en/latest/settings.html#settings-profiles | ||||
settings.register_profile("fast", max_examples=5, deadline=5000) | settings.register_profile("fast", max_examples=5, deadline=5000) | ||||
settings.register_profile("slow", max_examples=20, deadline=5000) | settings.register_profile("slow", max_examples=20, deadline=5000) | ||||
# Load the fast profile by default to overcome default hypothesis values | # Load the fast profile by default to overcome default hypothesis values | ||||
# (max_examples=100, deadline=200) that are unsuitable for our tests. | # (max_examples=100, deadline=200) that are unsuitable for our tests. | ||||
# This can still be overloaded via the --hypothesis-profile option. | # This can still be overloaded via the --hypothesis-profile option. | ||||
settings.load_profile("fast") | settings.load_profile("fast") | ||||
Show All 37 Lines |