diff --git a/conftest.py b/conftest.py new file mode 100644 index 00000000..474099e2 --- /dev/null +++ b/conftest.py @@ -0,0 +1,6 @@ +# Copyright (C) 2020 The Software Heritage developers +# See the AUTHORS file at the top-level directory of this distribution +# License: GNU General Public License version 3, or any later version +# See top-level LICENSE file for more information + +pytest_plugins = ["swh.storage.pytest_plugin"] diff --git a/setup.py b/setup.py index 72480105..442e90f1 100755 --- a/setup.py +++ b/setup.py @@ -1,79 +1,77 @@ #!/usr/bin/env python3 # Copyright (C) 2015-2020 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information from setuptools import setup, find_packages from os import path from io import open here = path.abspath(path.dirname(__file__)) # Get the long description from the README file with open(path.join(here, "README.md"), encoding="utf-8") as f: long_description = f.read() def parse_requirements(name=None): if name: reqf = "requirements-%s.txt" % name else: reqf = "requirements.txt" requirements = [] if not path.exists(reqf): return requirements with open(reqf) as f: for line in f.readlines(): line = line.strip() if not line or line.startswith("#"): continue requirements.append(line) return requirements setup( name="swh.storage", description="Software Heritage storage manager", long_description=long_description, long_description_content_type="text/markdown", python_requires=">=3.7", author="Software Heritage developers", author_email="swh-devel@inria.fr", url="https://forge.softwareheritage.org/diffusion/DSTO/", setup_requires=["setuptools-scm"], packages=find_packages(), use_scm_version=True, scripts=["bin/swh-storage-add-dir",], entry_points=""" [console_scripts] swh-storage=swh.storage.cli:main [swh.cli.subcommands] storage=swh.storage.cli:storage - [pytest11] - pytest_swh_storage=swh.storage.pytest_plugin """, install_requires=parse_requirements() + parse_requirements("swh"), extras_require={ "testing": (parse_requirements("test") + parse_requirements("swh-journal")), "schemata": ["SQLAlchemy"], "journal": parse_requirements("swh-journal"), }, include_package_data=True, classifiers=[ "Programming Language :: Python :: 3", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: OS Independent", "Development Status :: 5 - Production/Stable", ], project_urls={ "Bug Reports": "https://forge.softwareheritage.org/maniphest", "Funding": "https://www.softwareheritage.org/donate", "Source": "https://forge.softwareheritage.org/source/swh-storage", "Documentation": "https://docs.softwareheritage.org/devel/swh-storage/", }, ) diff --git a/swh/storage/tests/conftest.py b/swh/storage/tests/conftest.py index 7598d9a1..40905d5d 100644 --- a/swh/storage/tests/conftest.py +++ b/swh/storage/tests/conftest.py @@ -1,75 +1,74 @@ # Copyright (C) 2019-2020 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information import pytest import multiprocessing.util from hypothesis import settings try: import pytest_cov.embed except ImportError: pytest_cov = None from swh.model.tests.generate_testdata import gen_contents, gen_origins from swh.model.model import ( Content, Directory, Origin, OriginVisit, Release, Revision, SkippedContent, Snapshot, ) -from swh.storage.pytest_plugin import * # noqa # for retro compatibility OBJECT_FACTORY = { "content": Content.from_dict, "directory": Directory.from_dict, "origin": Origin.from_dict, "origin_visit": OriginVisit.from_dict, "release": Release.from_dict, "revision": Revision.from_dict, "skipped_content": SkippedContent.from_dict, "snapshot": Snapshot.from_dict, } # 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) settings.register_profile("slow", max_examples=20, deadline=5000) if pytest_cov is not None: # pytest_cov + multiprocessing can cause a segmentation fault when starting # the child process ; so we're # removing pytest-coverage's hook that runs when a child process starts. # This means code run in child processes won't be counted in the coverage # report, but this is not an issue because the only code that runs only in # child processes is the RPC server. for (key, value) in multiprocessing.util._afterfork_registry.items(): if value is pytest_cov.embed.multiprocessing_start: del multiprocessing.util._afterfork_registry[key] break else: assert False, "missing pytest_cov.embed.multiprocessing_start?" @pytest.fixture def swh_contents(swh_storage): contents = gen_contents(n=20) swh_storage.content_add([c for c in contents if c["status"] != "absent"]) swh_storage.skipped_content_add([c for c in contents if c["status"] == "absent"]) return contents @pytest.fixture def swh_origins(swh_storage): origins = gen_origins(n=100) swh_storage.origin_add(origins) return origins