From: Daniele Varrazzo Date: Sun, 12 Sep 2021 00:26:02 +0000 (+0200) Subject: Make sure tests can run without installing psycopg_pool X-Git-Tag: 3.0~82 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5696424d0d511512be348fef6413462aa153b01f;p=thirdparty%2Fpsycopg.git Make sure tests can run without installing psycopg_pool --- diff --git a/tests/pool/test_pool.py b/tests/pool/test_pool.py index 010e9483f..5700d458c 100644 --- a/tests/pool/test_pool.py +++ b/tests/pool/test_pool.py @@ -8,9 +8,17 @@ from collections import Counter import pytest import psycopg -import psycopg_pool as pool from psycopg.pq import TransactionStatus +pytestmark = [] + +try: + from psycopg_pool import ConnectionPool # noqa: F401 +except ImportError as ex: + pytestmark.append(pytest.mark.skip(reason=str(ex))) +else: + import psycopg_pool as pool + def test_defaults(dsn): with pool.ConnectionPool(dsn) as p: diff --git a/tests/pool/test_pool_async.py b/tests/pool/test_pool_async.py index 84befc020..efeb73fc8 100644 --- a/tests/pool/test_pool_async.py +++ b/tests/pool/test_pool_async.py @@ -7,7 +7,6 @@ from collections import Counter import pytest import psycopg -import psycopg_pool as pool from psycopg.pq import TransactionStatus from psycopg._compat import create_task @@ -19,6 +18,13 @@ pytestmark = [ ), ] +try: + from psycopg_pool import AsyncConnectionPool # noqa: F401 +except ImportError as ex: + pytestmark.append(pytest.mark.skip(reason=str(ex))) +else: + import psycopg_pool as pool + async def test_defaults(dsn): async with pool.AsyncConnectionPool(dsn) as p: diff --git a/tests/pool/test_sched.py b/tests/pool/test_sched.py index fefef8212..d35332fec 100644 --- a/tests/pool/test_sched.py +++ b/tests/pool/test_sched.py @@ -5,9 +5,12 @@ from threading import Thread import pytest -from psycopg_pool.sched import Scheduler +pytestmark = [pytest.mark.timing] -pytestmark = pytest.mark.timing +try: + from psycopg_pool.sched import Scheduler +except ImportError as ex: + pytestmark.append(pytest.mark.skip(reason=str(ex))) @pytest.mark.slow diff --git a/tests/pool/test_sched_async.py b/tests/pool/test_sched_async.py index 57aec74e7..2ea36dd1a 100644 --- a/tests/pool/test_sched_async.py +++ b/tests/pool/test_sched_async.py @@ -6,10 +6,14 @@ from functools import partial import pytest from psycopg._compat import create_task -from psycopg_pool.sched import AsyncScheduler pytestmark = [pytest.mark.asyncio, pytest.mark.timing] +try: + from psycopg_pool.sched import AsyncScheduler +except ImportError as ex: + pytestmark.append(pytest.mark.skip(reason=str(ex))) + @pytest.mark.slow async def test_sched():