Auto-activate for advanced_alchemy, alembic/, SQLAlchemyAsyncRepositoryService, SQLAlchemyAsyncConfig, repository_type, service_class, filters, or storage. Not for raw SQLAlchemy — use sqlspec.
日本語の概要は準備中です。原文の説明を表示しています。
Auto-activate for pytest_databases, Docker DB fixtures, PostgreSQL/pgvector/ParadeDB, MySQL/MariaDB, Oracle/SQL Server, CockroachDB, MongoDB, Redis/Valkey, BigQuery/Spanner, MinIO, or RustFS. Not for mocked DBs.
インストールする前に、エージェントに与えられる指示の中身を確認できます。
pytest-databases provides session-scoped, container-backed service fixtures.
This guidance targets the immutable v0.19.0 tag. Load only the plugin modules
the test suite uses. Consume a ready client fixture where one exists; otherwise
connect with the client already used by the project.
psycopg; do not await
their methods.conftest.py; do not load every
backend globally.pip install "pytest-databases[postgres]"
# conftest.py
pytest_plugins = ["pytest_databases.docker.postgres"]
The core pytest_databases pytest entry point supplies docker_client and
docker_service. Each database module supplies its own fixtures.
| Need | Use |
|---|---|
A ready psycopg connection | postgres_connection, a versioned PostgreSQL-family connection, or cockroachdb_connection |
| A ready vendor client | bigquery_client, spanner_connection, mongodb_connection, an Oracle connection, a GizmoSQL connection, or an Azure Blob container client |
| Service coordinates for the project's own client | The backend's *_service fixture |
| A specific PostgreSQL-family release | Matching *_NN_service, *_NN_connection, and *_NN_port fixtures |
| Parallel worker isolation | The backend's exact *_xdist_isolation_level fixture from xdist.md |
See reference.md for the exact plugin, service, and
ready-client matrix. Do not infer a *_connection fixture from a
*_service fixture's name.
pytest_databases.docker.<module> entries to
pytest_plugins.conftest.py. Use
environment variables only where 0.19.0 explicitly reads them; see
config.md.pytest-xdist, keep the default "database" isolation when the service
supports logical namespaces. Override the backend's exact isolation fixture
to "server" when each worker needs its own container.*_connection, *_client) exist for PostgreSQL-family, CockroachDB,
Oracle, GizmoSQL, BigQuery, Spanner, MongoDB, and Azure Blob. Service-only
backends (MySQL, MariaDB, SQL Server, YugabyteDB, Dolt, Redis, Dragonfly,
KeyDB, Valkey, Elasticsearch, MinIO, and RustFS) export *_service fixtures
but no ready client fixture. Note that redis, valkey, and elastic_search
still import their Python client package at module load time for readiness
checks, whereas mysql, mariadb, mssql, yugabyte, dolt, minio, and
rustfs require no Python client dependency to start the service.v0.19.0:
elasticsearch_service requests an undefined elasticsearch8_service fixture
(missing underscore) — request elasticsearch_8_service or
elasticsearch_7_service directly. oracle_startup_connection requests an
undefined oracle_23ai_startup_connection fixture — request
oracle_23ai_connection or oracle_18c_connection instead.pytest_databases.docker.* module names. AlloyDB Omni,
pgvector, and ParadeDB live in pytest_databases.docker.postgres (not
alloydb); Azurite / Azure Blob lives in pytest_databases.docker.azure_blob
(not azurite, with AzureBlobService, azure_blob_container_client, and
azure_blob_async_container_client); Elasticsearch lives in
pytest_databases.docker.elastic_search (not elasticsearch or
ElasticSearch); Dragonfly and KeyDB live in pytest_databases.docker.redis.postgres_connection is a
psycopg.Connection; call execute() directly.azure_blob_xdist_isolation_level; most others use
xdist_<backend>_isolation_level.pytest CLI flags. Version 0.19.0 registers no
pytest_addoption flags; configure services via session-scoped fixture
overrides or the environment variables in config.md.docker_service.*_port fixture or matching environment
variable only when a rootless/container-network constraint requires it
(redis_port, dragonfly_port, keydb_port, and valkey_port only read
*_service.port).pytest-databases>=0.19.0.pytest_plugins names an existing module from
reference.md.*_connection fixture.psycopg calls.import psycopg
pytest_plugins = ["pytest_databases.docker.postgres"]
def test_postgres_is_ready(
postgres_connection: psycopg.Connection,
) -> None:
row = postgres_connection.execute("SELECT 1").fetchone()
assert row == (1,)
postgres_connection is a synchronous psycopg.Connection. Use an async
driver only by constructing it separately from postgres_service.
Supported database patterns — ready-client and service-only examples.
Complete fixture matrix — exact 0.19.0 modules, classes, service fixtures, and client/provider fixtures.
Xdist parallel testing — supported isolation fixture names and helper functions.
Configuration — fixture overrides and environment variables implemented by 0.19.0.
Troubleshooting — runtime, plugin, client, and port failures.
Litestar testing — integrate container-backed services with Litestar test clients and dependency overrides.
まだレビューはありません。使ってみた感想をお寄せください。
概要と使いどころ
Auto-activate for advanced_alchemy, alembic/, SQLAlchemyAsyncRepositoryService, SQLAlchemyAsyncConfig, repository_type, service_class, filters, or storage. Not for raw SQLAlchemy — use sqlspec.
日本語の概要は準備中です。原文の説明を表示しています。
Auto-activate for Litestar, Controller, Router, @get/@post, FromPath, MsgspecDTO, OpenAPIConfig, Provide, FromDishka, Guard, ASGIMiddleware, HTTPException, ChannelsPlugin, or WebSocket. Not for standalone libs.
日本語の概要は準備中です。原文の説明を表示しています。
Auto-activate for Google ADK, LlmAgent, Runner, SQLSpecSessionService, google-genai, AgentRuntime, SpecTree, DynamicWorkflow, FunctionTool, or SSE agent chats. Not for offline ML training.
日本語の概要は準備中です。原文の説明を表示しています。
Auto-activate for litestar_autowire, AutowirePlugin, AutowireConfig, domain_packages, AutowireIntegration, AutowireLoader, or clear_autowire_cache. Not for manual Router composition — use explicit routes.
日本語の概要は準備中です。原文の説明を表示しています。
Auto-activate for uv build, hatch build, PyApp, PYAPP_*, wheel assets, GitHub release matrices, cargo-zigbuild, or python-build-standalone. Not for runtime deployment.
日本語の概要は準備中です。原文の説明を表示しています。
Auto-activate for Dockerfile, compose, Railway, Cloud Run, GKE, systemd, Kubernetes, Terraform, deploy scripts, or granian/litestar run at runtime. Not for packaging artifacts.
日本語の概要は準備中です。原文の説明を表示しています。