Reusable database fixtures for any and all databases.
Project description
Pytest Databases
Ready-made database fixtures for your pytest tests.
Features
- 🚀 Easy-to-use database fixtures
- 🔄 Support for multiple database types
- 🐳 Docker integration for isolated testing environments
- ⚡ Fast and efficient test execution
- 🔧 Highly configurable
pytest-databases uses the Docker Python SDK to manage the startup and shutdown of database services in containers. The following databases are currently available:
- Postgres: Version 12, 13, 14, 15, 16, 17 and 18 are available
- MySQL: Version 5.6, 5.7 and 8 are available
- Oracle: Version 18c XE and 23C Free are available
- SQL Server: Version 2022 is available
- Google AlloyDB Omni: Simplified Omni installation for easy testing.
- Google Spanner: The latest cloud-emulator from Google is available
- Google BigQuery: Unofficial BigQuery emulator
- CockroachDB: Version latest is available
- Redis: Latest version
- Valkey: Latest version
- Dragonfly: Latest version
- KeyDB: Latest version
- Elasticsearch: Version 7 and 8 are available
- Azure blob storage: Via azurite
- Minio: Latest version
Installation
Quick install for postgres:
pip install pytest-databases[postgres]
Quick Start
- Add to your pytest
conftest.py:
pytest_plugins = ["pytest_databases.docker.postgres"]
- Use in your tests:
from pytest_databases.docker.postgres import PostgresService
import psycopg
def test_one(postgres_service: PostgresService) -> None:
with psycopg.connect(
f"postgresql://{postgres_service.user}:{postgres_service.password}@{postgres_service.host}:{postgres_service.port}/{postgres_service.database}",
autocommit=True,
) as conn:
result = conn.execute("SELECT 1")
assert result
Documentation
Full documentation is available at https://litestar-org.github.io/pytest-databases/latest/
Contributing
Contributions are welcome! Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- The Litestar Framework team
- The pytest community
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_databases-0.16.0.tar.gz.
File metadata
- Download URL: pytest_databases-0.16.0.tar.gz
- Upload date:
- Size: 315.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5df82ac5650dc714d5341dad6cbe526dca183c430ef4a2e5de303267d420fbf0
|
|
| MD5 |
6820c3e058ff68c814e5f496206da0d8
|
|
| BLAKE2b-256 |
b46e49c740d77f80ff3c7c9bd8d791191555f987ed889a9cc243a1b7185e865c
|
Provenance
The following attestation bundles were made for pytest_databases-0.16.0.tar.gz:
Publisher:
release.yaml on litestar-org/pytest-databases
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_databases-0.16.0.tar.gz -
Subject digest:
5df82ac5650dc714d5341dad6cbe526dca183c430ef4a2e5de303267d420fbf0 - Sigstore transparency entry: 839038038
- Sigstore integration time:
-
Permalink:
litestar-org/pytest-databases@6cee1540096d9ec9605126760d646a7637ccc656 -
Branch / Tag:
refs/tags/v0.16.0 - Owner: https://github.com/litestar-org
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@6cee1540096d9ec9605126760d646a7637ccc656 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pytest_databases-0.16.0-py3-none-any.whl.
File metadata
- Download URL: pytest_databases-0.16.0-py3-none-any.whl
- Upload date:
- Size: 33.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c9d78dd89f67aee511b801533affb1af82ea77bafe23b08d7b762d8508a5cd2
|
|
| MD5 |
ea225349438b5bb4caa33e8a4f67ed09
|
|
| BLAKE2b-256 |
dea63665fc96d3b3e17a54bdd9488d870e923d34330e71be7e02989f8619d14f
|
Provenance
The following attestation bundles were made for pytest_databases-0.16.0-py3-none-any.whl:
Publisher:
release.yaml on litestar-org/pytest-databases
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_databases-0.16.0-py3-none-any.whl -
Subject digest:
1c9d78dd89f67aee511b801533affb1af82ea77bafe23b08d7b762d8508a5cd2 - Sigstore transparency entry: 839038040
- Sigstore integration time:
-
Permalink:
litestar-org/pytest-databases@6cee1540096d9ec9605126760d646a7637ccc656 -
Branch / Tag:
refs/tags/v0.16.0 - Owner: https://github.com/litestar-org
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@6cee1540096d9ec9605126760d646a7637ccc656 -
Trigger Event:
release
-
Statement type: