"tests.fix_faker",
"tests.fix_proxy",
"tests.fix_psycopg",
+ "tests.pool.fix_pool",
)
def pytest_configure(config):
- # register slow marker
- config.addinivalue_line(
- "markers", "slow: this test is kinda slow (skip with -m 'not slow')"
- )
-
- # There are troubles on travis with these kind of tests and I cannot
- # catch the exception for my life.
- config.addinivalue_line(
- "markers", "subprocess: the test import psycopg after subprocess"
- )
-
- config.addinivalue_line(
- "markers",
+ markers = [
+ "slow: this test is kinda slow (skip with -m 'not slow')",
+ # There are troubles on travis with these kind of tests and I cannot
+ # catch the exception for my life.
+ "subprocess: the test import psycopg after subprocess",
"timing: the test is timing based and can fail on cheese hardware",
- )
-
- config.addinivalue_line(
- "markers",
"dns: the test requires dnspython to run",
- )
-
- config.addinivalue_line(
- "markers",
"postgis: the test requires the PostGIS extension to run",
- )
+ ]
+
+ for marker in markers:
+ config.addinivalue_line("markers", marker)
def pytest_addoption(parser):
--- /dev/null
+import pytest
+
+
+def pytest_configure(config):
+ config.addinivalue_line(
+ "markers", "pool: test related to the psycopg_pool package"
+ )
+
+
+def pytest_collection_modifyitems(items):
+ # Add the pool markers to all the tests in the pool package
+ for item in items:
+ if "/pool/" in item.nodeid:
+ item.add_marker(pytest.mark.pool)
from psycopg.pq import TransactionStatus
from psycopg._compat import Counter
-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
+except ImportError:
+ # Tests should have been skipped if the package is not available
+ pass
def test_package_version(mypy):
from psycopg.pq import TransactionStatus
from psycopg._compat import create_task, Counter
+try:
+ import psycopg_pool as pool
+except ImportError:
+ # Tests should have been skipped if the package is not available
+ pass
+
pytestmark = [
pytest.mark.asyncio,
pytest.mark.skipif(
),
]
-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:
import pytest
-pytestmark = [pytest.mark.timing]
-
try:
from psycopg_pool.sched import Scheduler
-except ImportError as ex:
- pytestmark.append(pytest.mark.skip(reason=str(ex)))
+except ImportError:
+ # Tests should have been skipped if the package is not available
+ pass
+
+pytestmark = [pytest.mark.timing]
@pytest.mark.slow
from psycopg._compat import create_task
-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)))
+except ImportError:
+ # Tests should have been skipped if the package is not available
+ pass
+
+pytestmark = [pytest.mark.asyncio, pytest.mark.timing]
@pytest.mark.slow