Skip to main content

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.toml and 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/-m like pytest).
  • pytest-chronicle query timeline – colored TTY timeline of recent runs for matching tests.
  • 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 = "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_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

Project details


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.2.tar.gz (34.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_chronicle-0.2.2-py3-none-any.whl (45.3 kB view details)

Uploaded Python 3

File details

Details for the file pytest_chronicle-0.2.2.tar.gz.

File metadata

  • Download URL: pytest_chronicle-0.2.2.tar.gz
  • Upload date:
  • Size: 34.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.15

File hashes

Hashes for pytest_chronicle-0.2.2.tar.gz
Algorithm Hash digest
SHA256 3491724b137bebd9caa76e53516ef563fc81b3c4985ef9667325f7925aaab18a
MD5 e68d6c63790b3d733a1ff0102c774f09
BLAKE2b-256 52667d3acf9a3c99350f88b5737064781d640090c499fb450cee63e08edb57da

See more details on using hashes here.

File details

Details for the file pytest_chronicle-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_chronicle-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 25d996577af6f0cd514421647a91d16a95a01a59c6f46163b09c7d67a1b29d2e
MD5 70d15af4502c5dc2ec546fb3b6fd3e37
BLAKE2b-256 1ee10a60676b25fa7e0ea2c9a06f7b4c70f38e9d4b5e33634c527c8321fe2920

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page