Skip to main content

pytest-chronicle

Searchable git-aware pytest history with a lean CLI and easy storage backends.

Pin down regressions. Squash bugs. Join the Federation today.

pytest-chronicle demo

What it does

Running pytest:

  • Emits per-test records (result/stdout/stderr/traceback)
  • Persists test result records to SQLite / Postgres (or implement your own storage backend) with:
    • git/CI metadata
    • pytest invocation parameters
    • timestamps
    • user-defined labels

With the pytest-chronicle CLI you can now query the test result history.

Install

pip install pytest-chronicle

Quickstart

pytest-chronicle init                                     # create config + local sqlite
pytest -q                                                 # auto-ingests using config/env/fallback SQLite
pytest-chronicle query last-green --format json --pretty    # ask questions
pytest-chronicle query last-red tests/test_mod.py::Test::test_case   # pytest-style selectors

Common commands

  • pytest-chronicle init – scaffold .pytest-chronicle.toml and an async SQLite DB.
  • pytest-chronicle ingest --jsonl <path> – ingest JSONL/summary artifacts.
  • pytest-chronicle query last-red|last-green|errors|flipped-green|compare – history lookups. Filters: -k/-m like pytest, --labels, --since, --until, --branch/--commit, positional pytest-style selectors, or --pytest-select "-m 'slow' -k expr path::nodeid". Outputs include per-test runtime with smart units (μs/ms/s) and git metadata; text mode shows colored tables by default (--no-color to disable). Slow tests (≥1s) are highlighted yellow, very slow (≥5s) in red. Use --show-marks to display test marks.
  • pytest-chronicle query timeline – colored TTY timeline of recent runs for matching tests (? marks not-run/filtered cases). Use -t/--show-times to display execution times.
  • pytest-chronicle query slowest – tests sorted by execution time (slowest first); use --status failed to find slowest failures.
  • pytest-chronicle query stats – per-test failure rates, pass/fail counts, and timing stats; use --min-runs N to filter low-sample tests, --sort-by failure-rate|avg-time|max-time|total-runs to rank.
  • pytest-chronicle run <project> -- <pytest args> – run pytest under uv, 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, legacy TEST_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 = "ci-smoke,linux"   # labels/tags (comma-separated)
    
  • Typical flow: use SQLite for local dev (via init); point env or config at Postgres for CI/prod. No other changes needed.
  • If you skip --project during init, it is auto-detected from pyproject.toml (or the current folder name); the CLI tells you how to change it later.

Pytest plugin (auto ingestion)

  • Install the package; the pytest_chronicle plugin 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-ingest to 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

Metadata

Release files for pytest-chronicle 0.4.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-chronicle 0.4.6
File Size Uploaded
pytest_chronicle-0.4.6.tar.gz 43.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-chronicle 0.4.6
File Interpreter ABI Platform
pytest_chronicle-0.4.6-py3-none-any.whl Python 3 none any Details

Total release size: 95.3 kB

Release files / pytest_chronicle-0.4.6.tar.gz

Download URL pytest_chronicle-0.4.6.tar.gz
Size 43.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c1d70c0aa909da59812083563c83dc34b5e67bfdd5113d0a8fc0c7c5dc414716
BLAKE2b-256 checksum
How to use checksums
8633ef13da7cd4f1e401a7d115a493f4398ae62fbe9e3a104fb5f2f7d91c1aab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.15

Release files / pytest_chronicle-0.4.6-py3-none-any.whl

Download URL pytest_chronicle-0.4.6-py3-none-any.whl
Size 52.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f2edd5b4f7551e2a73fe4c1cf10fa3ba78797a77211be46fbf90da78cb23c08b
BLAKE2b-256 checksum
How to use checksums
e283ec1783422ecbda813794ac7fc22ec11d633b738bcb24c694cb3140515bb0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.15

Release history Release notifications | RSS feed

This release

0.4.6 This release

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.0.3

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page