diff --git a/requirements-db.txt b/requirements-db.txt --- a/requirements-db.txt +++ b/requirements-db.txt @@ -1,4 +1,4 @@ # requirements for swh.core.db psycopg2 typing-extensions -pytest-postgresql + diff --git a/requirements-test-db.txt b/requirements-test-db.txt --- a/requirements-test-db.txt +++ b/requirements-test-db.txt @@ -1 +1 @@ - +pytest-postgresql diff --git a/swh/core/db/pytest_plugin.py b/swh/core/db/pytest_plugin.py --- a/swh/core/db/pytest_plugin.py +++ b/swh/core/db/pytest_plugin.py @@ -10,14 +10,20 @@ import psycopg2 import pytest -from pytest_postgresql import factories -from pytest_postgresql.janitor import DatabaseJanitor, Version from swh.core.utils import numfile_sortkey as sortkey logger = logging.getLogger(__name__) +try: + from pytest_postgresql import factories + from pytest_postgresql.janitor import DatabaseJanitor, Version +except ImportError: + error_msg = "The module pytest_plugin requires dependency pytest-postgresql module" + raise EnvironmentError(error_msg) + + class SWHDatabaseJanitor(DatabaseJanitor): """SWH database janitor implementation with a a different setup/teardown policy than than the stock one. Instead of dropping, creating and initializing the database for