Loading...
Loading...
Auto-activate for pytest_databases, Docker DB fixtures, PostgreSQL/pgvector/AlloyDB Omni/MySQL/Oracle/MSSQL/CockroachDB/Yugabyte/MongoDB/GizmoSQL/Redis/Spanner/BigQuery/Azurite/MinIO tests. Not for mocked DBs.
npx skill4agent add litestar-org/litestar-skills pytest-databasesreferences/conftest.pypytest_plugins = ["pytest_databases.docker.postgres"]def test_database(postgres_service):
# Use postgres_service.host, .port, etc.
passxdistdatabaseserverreferences/xdist.mdconftest.pypytest_plugins = [...]postgres_servicemysql_servicepytest -n autoreferences/xdist.mdimport pytest
pytest_plugins = ["pytest_databases.docker.postgres"]
@pytest.mark.anyio
async def test_user_insert(postgres_service, postgres_connection):
await postgres_connection.execute(
"INSERT INTO users (email) VALUES ($1)", "alice@example.com"
)
row = await postgres_connection.fetchrow(
"SELECT email FROM users WHERE email = $1", "alice@example.com"
)
assert row["email"] == "alice@example.com"AsyncTestClient