Skip to main content

Reusable pytest results ingestion tooling with database export and CLI helpers.

Project description

pytest-chronicle

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

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

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 (time_sec) and git metadata; text mode shows colored tables by default (--no-color to disable).
  • pytest-chronicle query timeline – colored TTY timeline of recent runs for matching tests (? marks not-run/filtered cases).
  • 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

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.3.1.tar.gz (38.1 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.3.1-py3-none-any.whl (48.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pytest_chronicle-0.3.1.tar.gz
Algorithm Hash digest
SHA256 32f16d7b9933c907960654f4d330209c99a2e9a0c72761f070e16d8669a6c7cc
MD5 93e4f4333c636306391b2fd6d0a27a80
BLAKE2b-256 734672f9567a02773f52cdee452cf93347bc392b3e0b8d28e3acf1d444ba7074

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_chronicle-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c4e9fdda5545dad7bcbf50877bd1c7f55cf8487a405366b1eefea09a0b4d5203
MD5 2571284095aca322adffc2e2ece89107
BLAKE2b-256 6837145f70d03f0b786fe41317ef3b9e99b94da6e31b0466547a83d61ff1b0e8

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