From 9437a643ad734f9fbfb0a8e2bcc939120f22e5e8 Mon Sep 17 00:00:00 2001
From: "Antoine R. Dumont (@ardumont)" <ardumont@softwareheritage.org>
Date: Tue, 1 Sep 2020 17:43:01 +0200
Subject: [PATCH] pytest: Define plugin and declare it in the root conftest

Then drop all unneeded and indirect imports
---
 MANIFEST.in                                             | 1 +
 conftest.py                                             | 2 +-
 swh/lister/bitbucket/tests/conftest.py                  | 1 -
 swh/lister/cgit/tests/conftest.py                       | 1 -
 swh/lister/cran/tests/conftest.py                       | 2 --
 swh/lister/debian/tests/conftest.py                     | 3 +--
 swh/lister/gitea/tests/conftest.py                      | 6 ------
 swh/lister/github/tests/conftest.py                     | 1 -
 swh/lister/gitlab/tests/conftest.py                     | 6 ------
 swh/lister/gnu/tests/conftest.py                        | 6 ------
 swh/lister/launchpad/tests/conftest.py                  | 1 -
 swh/lister/npm/tests/conftest.py                        | 4 +---
 swh/lister/packagist/tests/conftest.py                  | 4 +---
 swh/lister/phabricator/tests/conftest.py                | 4 +---
 swh/lister/pypi/tests/conftest.py                       | 4 +---
 swh/lister/{core/tests/conftest.py => pytest_plugin.py} | 2 ++
 16 files changed, 9 insertions(+), 39 deletions(-)
 delete mode 100644 swh/lister/bitbucket/tests/conftest.py
 delete mode 100644 swh/lister/cgit/tests/conftest.py
 delete mode 100644 swh/lister/gitea/tests/conftest.py
 delete mode 100644 swh/lister/github/tests/conftest.py
 delete mode 100644 swh/lister/gitlab/tests/conftest.py
 delete mode 100644 swh/lister/gnu/tests/conftest.py
 rename swh/lister/{core/tests/conftest.py => pytest_plugin.py} (99%)

diff --git a/MANIFEST.in b/MANIFEST.in
index c31438fc..2f90a77b 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -2,6 +2,7 @@ include Makefile
 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
index 1759d04d..e709cbe5 100644
--- a/conftest.py
+++ b/conftest.py
@@ -7,7 +7,7 @@ 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"
 
diff --git a/swh/lister/bitbucket/tests/conftest.py b/swh/lister/bitbucket/tests/conftest.py
deleted file mode 100644
index 507fef91..00000000
--- 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
index 507fef91..00000000
--- 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
index 30d88c38..7b7777a2 100644
--- 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
index 4b2ab4c3..bea3f46c 100644
--- 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 pytest_postgresql.janitor import DatabaseJanitor
 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
index c18796b0..00000000
--- 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
index 507fef91..00000000
--- 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
index 24269871..00000000
--- 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
index a4b2b262..00000000
--- 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
index d1dd73ed..655d8589 100644
--- 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
index bfa555f4..507064d6 100644
--- 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
index 1eafc36a..81f8e449 100644
--- 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
index 2713ce9c..19261220 100644
--- 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
index 658fdcb7..5d235f7a 100644
--- 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
similarity index 99%
rename from swh/lister/core/tests/conftest.py
rename to swh/lister/pytest_plugin.py
index 647fd466..d58195c9 100644
--- 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,6 +12,7 @@ from sqlalchemy import create_engine
 from swh.lister import get_lister, SUPPORTED_LISTERS
 from swh.lister.core.models import initialize
 
+
 logger = logging.getLogger(__name__)
 
 
-- 
GitLab