diff --git a/MANIFEST.in b/MANIFEST.in --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,6 +2,7 @@ include README include requirements*.txt include version.txt +include conftest.py include swh/lister/cran/list_all_packages.R recursive-include swh/lister/*/tests/data/ * recursive-include swh py.typed diff --git a/conftest.py b/conftest.py --- a/conftest.py +++ b/conftest.py @@ -5,24 +5,6 @@ import os -import pytest - -pytest_plugins = ["swh.scheduler.pytest_plugin"] +pytest_plugins = ["swh.scheduler.pytest_plugin", "swh.lister.pytest_plugin"] os.environ["LC_ALL"] = "C.UTF-8" - - -@pytest.fixture -def mock_get_scheduler(monkeypatch, swh_scheduler): - """Override the get_scheduler function in swh.lister.core.lister_base, to - return the swh_scheduler fixture. - """ - from swh.lister.core import lister_base - - # Match the signature from swh.scheduler.get_scheduler - def get_scheduler(cls, args={}): - return swh_scheduler - - monkeypatch.setattr(lister_base, "get_scheduler", get_scheduler) - - yield monkeypatch diff --git a/swh/lister/bitbucket/tests/conftest.py b/swh/lister/bitbucket/tests/conftest.py deleted file mode 100644 --- a/swh/lister/bitbucket/tests/conftest.py +++ /dev/null @@ -1 +0,0 @@ -from swh.lister.core.tests.conftest import * # noqa diff --git a/swh/lister/cgit/tests/conftest.py b/swh/lister/cgit/tests/conftest.py deleted file mode 100644 --- a/swh/lister/cgit/tests/conftest.py +++ /dev/null @@ -1 +0,0 @@ -from swh.lister.core.tests.conftest import * # noqa diff --git a/swh/lister/cran/tests/conftest.py b/swh/lister/cran/tests/conftest.py --- a/swh/lister/cran/tests/conftest.py +++ b/swh/lister/cran/tests/conftest.py @@ -5,8 +5,6 @@ import pytest -from swh.lister.core.tests.conftest import * # noqa - @pytest.fixture def lister_cran(swh_listers): diff --git a/swh/lister/debian/tests/conftest.py b/swh/lister/debian/tests/conftest.py --- a/swh/lister/debian/tests/conftest.py +++ b/swh/lister/debian/tests/conftest.py @@ -1,4 +1,4 @@ -# Copyright (C) 2019 The Software Heritage developers +# 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 @@ -9,7 +9,6 @@ from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker -from swh.lister.core.tests.conftest import * # noqa from swh.lister.core.models import SQLBase from swh.lister.debian import debian_init diff --git a/swh/lister/gitea/tests/conftest.py b/swh/lister/gitea/tests/conftest.py deleted file mode 100644 --- a/swh/lister/gitea/tests/conftest.py +++ /dev/null @@ -1,6 +0,0 @@ -# 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 - -from swh.lister.core.tests.conftest import * # noqa diff --git a/swh/lister/github/tests/conftest.py b/swh/lister/github/tests/conftest.py deleted file mode 100644 --- a/swh/lister/github/tests/conftest.py +++ /dev/null @@ -1 +0,0 @@ -from swh.lister.core.tests.conftest import * # noqa diff --git a/swh/lister/gitlab/tests/conftest.py b/swh/lister/gitlab/tests/conftest.py deleted file mode 100644 --- a/swh/lister/gitlab/tests/conftest.py +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright (C) 2019 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 swh.lister.core.tests.conftest import * # noqa diff --git a/swh/lister/gnu/tests/conftest.py b/swh/lister/gnu/tests/conftest.py deleted file mode 100644 --- a/swh/lister/gnu/tests/conftest.py +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright (C) 2019 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 swh.lister.core.tests.conftest import * # noqa diff --git a/swh/lister/launchpad/tests/conftest.py b/swh/lister/launchpad/tests/conftest.py --- a/swh/lister/launchpad/tests/conftest.py +++ b/swh/lister/launchpad/tests/conftest.py @@ -3,7 +3,6 @@ # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information -from swh.lister.core.tests.conftest import * # noqa from datetime import datetime import json import os diff --git a/swh/lister/npm/tests/conftest.py b/swh/lister/npm/tests/conftest.py --- a/swh/lister/npm/tests/conftest.py +++ b/swh/lister/npm/tests/conftest.py @@ -1,12 +1,10 @@ -# Copyright (C) 2019 The Software Heritage developers +# 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 -from swh.lister.core.tests.conftest import * # noqa - @pytest.fixture def lister_npm(swh_listers): diff --git a/swh/lister/packagist/tests/conftest.py b/swh/lister/packagist/tests/conftest.py --- a/swh/lister/packagist/tests/conftest.py +++ b/swh/lister/packagist/tests/conftest.py @@ -1,12 +1,10 @@ -# Copyright (C) 2019 The Software Heritage developers +# 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 -from swh.lister.core.tests.conftest import * # noqa - @pytest.fixture def lister_packagist(swh_listers): diff --git a/swh/lister/phabricator/tests/conftest.py b/swh/lister/phabricator/tests/conftest.py --- a/swh/lister/phabricator/tests/conftest.py +++ b/swh/lister/phabricator/tests/conftest.py @@ -1,12 +1,10 @@ -# Copyright (C) 2019 The Software Heritage developers +# 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 -from swh.lister.core.tests.conftest import * # noqa - @pytest.fixture def lister_phabricator(swh_listers): diff --git a/swh/lister/pypi/tests/conftest.py b/swh/lister/pypi/tests/conftest.py --- a/swh/lister/pypi/tests/conftest.py +++ b/swh/lister/pypi/tests/conftest.py @@ -1,12 +1,10 @@ -# Copyright (C) 2019 The Software Heritage developers +# 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 -from swh.lister.core.tests.conftest import * # noqa - @pytest.fixture def lister_pypi(swh_listers): diff --git a/swh/lister/core/tests/conftest.py b/swh/lister/pytest_plugin.py rename from swh/lister/core/tests/conftest.py rename to swh/lister/pytest_plugin.py --- a/swh/lister/core/tests/conftest.py +++ b/swh/lister/pytest_plugin.py @@ -4,6 +4,7 @@ # See top-level LICENSE file for more information import logging + import pytest from sqlalchemy import create_engine @@ -11,9 +12,26 @@ from swh.lister import get_lister, SUPPORTED_LISTERS from swh.lister.core.models import initialize + logger = logging.getLogger(__name__) +@pytest.fixture +def mock_get_scheduler(monkeypatch, swh_scheduler): + """Override the get_scheduler function in swh.lister.core.lister_base, to + return the swh_scheduler fixture. + """ + from swh.lister.core import lister_base + + # Match the signature from swh.scheduler.get_scheduler + def get_scheduler(cls, args={}): + return swh_scheduler + + monkeypatch.setattr(lister_base, "get_scheduler", get_scheduler) + + yield monkeypatch + + @pytest.fixture def lister_db_url(postgresql_proc, postgresql): db_url = "postgresql://{user}@{host}:{port}/{dbname}".format(