Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/conftest.py
# Copyright (C) 2018-2021 The Software Heritage developers | # Copyright (C) 2018-2021 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 Affero General Public License version 3, or any later version | # License: GNU Affero 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 json | import json | ||||
import os | import os | ||||
import shutil | import shutil | ||||
from subprocess import PIPE, run | from subprocess import PIPE, run | ||||
import sys | import sys | ||||
from typing import Any, Dict, List, Optional | from typing import Any, Dict, List, Optional | ||||
from hypothesis import HealthCheck | from hypothesis import HealthCheck, settings | ||||
from hypothesis import __version_info__ as hypothesis_version | |||||
from hypothesis import settings | |||||
import pytest | import pytest | ||||
from django.core.cache import cache | from django.core.cache import cache | ||||
from rest_framework.test import APIClient, APIRequestFactory | from rest_framework.test import APIClient, APIRequestFactory | ||||
from swh.model.hashutil import ALGORITHMS, hash_to_bytes | from swh.model.hashutil import ALGORITHMS, hash_to_bytes | ||||
from swh.storage.algos.origin import origin_get_latest_visit_status | from swh.storage.algos.origin import origin_get_latest_visit_status | ||||
from swh.storage.algos.snapshot import snapshot_get_all_branches, snapshot_get_latest | from swh.storage.algos.snapshot import snapshot_get_all_branches, snapshot_get_latest | ||||
Show All 11 Lines | ctags_json_missing = ( | ||||
or b"+json" not in run(["ctags", "--version"], stdout=PIPE).stdout | or b"+json" not in run(["ctags", "--version"], stdout=PIPE).stdout | ||||
) | ) | ||||
fossology_missing = shutil.which("nomossa") is None | fossology_missing = shutil.which("nomossa") is None | ||||
# Register some hypothesis profiles | # Register some hypothesis profiles | ||||
settings.register_profile("default", settings()) | settings.register_profile("default", settings()) | ||||
suppress_health_check = [HealthCheck.too_slow, HealthCheck.filter_too_much] | # we use getattr here to keep mypy happy regardless hypothesis version | ||||
if hypothesis_version >= (5, 49): | function_scoped_fixture_check = ( | ||||
suppress_health_check.append(HealthCheck.function_scoped_fixture) | [getattr(HealthCheck, "function_scoped_fixture")] | ||||
if hasattr(HealthCheck, "function_scoped_fixture") | |||||
else [] | |||||
) | |||||
suppress_health_check = [ | |||||
HealthCheck.too_slow, | |||||
HealthCheck.filter_too_much, | |||||
] + function_scoped_fixture_check | |||||
settings.register_profile( | settings.register_profile( | ||||
"swh-web", settings(deadline=None, suppress_health_check=suppress_health_check,), | "swh-web", settings(deadline=None, suppress_health_check=suppress_health_check,), | ||||
) | ) | ||||
settings.register_profile( | settings.register_profile( | ||||
"swh-web-fast", | "swh-web-fast", | ||||
settings( | settings( | ||||
▲ Show 20 Lines • Show All 332 Lines • Show Last 20 Lines |