Skip to content

no-raw-connection-in-tests

Do not acquire raw database connections in tests.

Why

Tests that reach through a pool couple assertions and setup to persistence internals, bypass the application boundary, and duplicate transaction ownership.

Fix

Exercise the owning store/service API or expose a narrow test-support fixture. Use an exact SARJ429 suppression for a test whose purpose is explicitly connection or transaction behavior.

Examples

Before — flagged A test helper reaches directly through its pool
tests/test_orders.py
async def load_rows(pool: AsyncConnectionPool):
async with pool.connection() as conn:
return await conn.execute("SELECT 1")
After — preferred A test reads through the owning store API
tests/test_orders.py
async def load_rows(store: OrderStore):
return await store.list_orders()