Reusable pytest results ingestion tooling with database export and CLI helpers.
Project description
pytest-chronicle
Traceable pytest history: capture results, ingest into SQLite or Postgres, and answer “when did this test last go red?” or “which commit flipped it green?”.
What it does
- Pytest plugin emits per-test JSONL records (stdout/stderr/traceback included).
- Ingestion stamps runs with git/CI metadata and writes to SQLite or Postgres.
- CLI queries last failures, error details, flip-to-green commits, and branch/commit diffs with pytest-like selectors.
Install
uv pip install pytest-chronicle
Quickstart
pytest-chronicle init --project my-project --suite pytest # create config + local sqlite
pytest -q # auto-ingests using config/env/fallback SQLite
pytest-chronicle query last-red --format json --pretty # ask questions
Common commands
pytest-chronicle init– scaffold.pytest-chronicle.tomland an async SQLite DB.pytest-chronicle ingest --jsonl <path>– ingest JSONL/summary artifacts.pytest-chronicle query last-red|errors|flipped-green|compare– history lookups (-k/-mlike pytest).pytest-chronicle run <project> -- <pytest args>– run pytest underuv, collect artifacts, optionally ingest.pytest-chronicle backfill– ingest many summary.json files.pytest-chronicle export-sqlite/import-sqlite– migrate between backends.pytest-chronicle db upgrade– apply Alembic migrations.pytest-chronicle config show|set– view or set repo defaults.
Configuration & defaults
- Precedence: CLI flag
--database-url> env (PYTEST_RESULTS_DB_URL, legacyTEST_RESULTS_DATABASE_URL/SCS_DATABASE_URL) >.pytest-chronicle.toml> fallback SQLite at<repo>/.pytest-chronicle/chronicle.db(async). - Example config:
[chronicle] database_url = "postgresql+asyncpg://user:pass@host/db" project = "my-project" suite = "pytest"
- Typical flow: use SQLite for local dev (via
init); point env or config at Postgres for CI/prod. No other changes needed.
Pytest plugin (auto ingestion)
- Install the package; the
pytest_chronicleplugin is auto-discovered. - If a database is configured via env/config (or fallback SQLite), the plugin will ingest automatically at session end. You can still pass
--chronicle-db <url>to override, or--chronicle-no-ingestto skip. - Default JSONL path:
.artifacts/test-results/chronicle-results.jsonl(created automatically).
More docs
- Detailed guide:
docs/guide.md - Backend abstraction:
docs/storage-backends.md
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
pytest_chronicle-0.2.1.tar.gz
(33.4 kB
view details)
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_chronicle-0.2.1.tar.gz.
File metadata
- Download URL: pytest_chronicle-0.2.1.tar.gz
- Upload date:
- Size: 33.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b20ca66b4f22bbee4c51891d6885be79b58732557dc0308612bc6b74cb64c98
|
|
| MD5 |
5e890a2ef3f2562fdc68b8d9f9e72120
|
|
| BLAKE2b-256 |
4b68846c2db6df8fd05187234a0549879a45b1f85d1d695e3033475049a60a61
|
File details
Details for the file pytest_chronicle-0.2.1-py3-none-any.whl.
File metadata
- Download URL: pytest_chronicle-0.2.1-py3-none-any.whl
- Upload date:
- Size: 44.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
046acbc13e2f9b6760f9a0e71fca8bf3a9afea3e6244389d6d0cb12256b2bf42
|
|
| MD5 |
6403d39a114919692dc71f8f0f3aa79a
|
|
| BLAKE2b-256 |
4c7cbb18281dec3192cf9bdb03ba3c34d1d881bec160c7e3ed2ebc3c75a409dc
|