Add your description here
Project description
Test Scenarios
Test Scenarios is a small Python library that simplifies writing integration tests by providing easy-to-use scenario definitions backed by MongoDB. It makes setup and teardown of test data explicit and repeatable, so your integration tests stay reliable and easy to reason about.
Key features
- Minimal, opinionated API for defining scenarios (collections + documents)
- Easy pytest integration via fixtures
- Works with local or remote MongoDB instances
- Focused on readability and test determinism
Installation
For development:
python -m venv .venv
source .venv/bin/activate
pip install -e .
pip install -r requirements-dev.txt
If published to PyPI, you can install the package:
pip install pytest-scenarios
Or with uv:
uv add pytest-scenarios --dev
Or with Poetry:
poetry add pytest-scenarios --group dev
Configuration
Set the MongoDB connection URI via environment variable:
export MONGODB_URI="mongodb://localhost:27017"
Getting started (pytest)
A simple test:
def test_example(
scenario_builder: ScenarioBuilder, db: Database
):
"""Test that scenario_fixture allows scenario creation"""
inserted_ids_by_collection = scenario_builder.create(
{
"customers": [
{"name": "Alice", "status": "inactive"},
{"name": "Louis", "age": 25},
],
"orders": [
{
"id": "order_001",
"items": [
{"price": 19.99, "product_id": "book_123", "quantity": 1}
],
},
{
"id": "order_002",
"items": None,
"tax": 0.2,
},
],
}
)
for collection_name, inserted_ids in inserted_ids_by_collection:
assert len(inserted_ids) == 2
Run tests:
pytest -q
Contributing
Contributions welcome. Please add tests for new features and follow the project's coding standards.
License
MIT
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_scenarios-0.0.3.tar.gz.
File metadata
- Download URL: pytest_scenarios-0.0.3.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5dc831bc2c03eefa54ebfed84a612d6bb7a003306aae463b28a388e2597c598
|
|
| MD5 |
3a234115a8fb8a3cf983f5b4374de5ad
|
|
| BLAKE2b-256 |
5413a2a140c16674dcd059305be146911ea7db3b76a00a311881fc60845cd687
|
Provenance
The following attestation bundles were made for pytest_scenarios-0.0.3.tar.gz:
Publisher:
release.yaml on carlosvin/pytest-scenarios
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_scenarios-0.0.3.tar.gz -
Subject digest:
d5dc831bc2c03eefa54ebfed84a612d6bb7a003306aae463b28a388e2597c598 - Sigstore transparency entry: 625287058
- Sigstore integration time:
-
Permalink:
carlosvin/pytest-scenarios@7ece9052a07bf2f06227e609637804308306fb0b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/carlosvin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@7ece9052a07bf2f06227e609637804308306fb0b -
Trigger Event:
pull_request
-
Statement type:
File details
Details for the file pytest_scenarios-0.0.3-py3-none-any.whl.
File metadata
- Download URL: pytest_scenarios-0.0.3-py3-none-any.whl
- Upload date:
- Size: 5.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 |
78921ae228930dde880c1f003044c06895297139c074211c50a4b876a17a41d4
|
|
| MD5 |
396a5264d0a86b323bd7dd3772a3d6ef
|
|
| BLAKE2b-256 |
83989228dfbb9b6cfcd2b7310e421fc4b693f04bece95e426d268ea2dc6573dd
|
Provenance
The following attestation bundles were made for pytest_scenarios-0.0.3-py3-none-any.whl:
Publisher:
release.yaml on carlosvin/pytest-scenarios
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_scenarios-0.0.3-py3-none-any.whl -
Subject digest:
78921ae228930dde880c1f003044c06895297139c074211c50a4b876a17a41d4 - Sigstore transparency entry: 625287071
- Sigstore integration time:
-
Permalink:
carlosvin/pytest-scenarios@7ece9052a07bf2f06227e609637804308306fb0b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/carlosvin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@7ece9052a07bf2f06227e609637804308306fb0b -
Trigger Event:
pull_request
-
Statement type: