Skip to main content

Notebook-friendly approval testing for Python and Jupyter

Project description

nbapproval

Notebook-friendly approval testing for Python and Jupyter.

nbapproval lets you compare actual notebook outputs to approved values, store approvals in a separate approvals notebook, and fail CI runs when approvals are missing or mismatched.

Install

pip install nbapproval

Quick Start

from nbapproval import approval_test

approval_test(
    "Simple approval check",
    {"value": 42},
)

approval_test.assert_all_approved()

API (Terse-First)

Primary call supports concise notebook usage:

approval_test(description, actual, sort_by=None)

Also supported:

  • id alias for test_id
  • desc alias for description
  • keyword form: actual=...
  • automatic test_id derivation from description when omitted
  • pandas DataFrame values as actual (auto-converted to stable records)

Examples:

# Explicit id + keyword style
approval_test(
    id="known_holiday_checkpoints_match_expected_names_for_specific_dates",
    desc="Known holiday checkpoints match expected names for specific dates.",
    actual=approval_test.to_iso_records(actual_df),
    sort_by=["Date", "Expected"],
)

# Terse positional style (id auto-derived from description)
approval_test(
    "Known holiday checkpoints match expected names for specific dates.",
    actual_df,
    sort_by=["Date", "Expected"],
)

approval_test.from_dataframe(...) remains available, but is optional now because the main call handles DataFrames directly.

Testing

Run tests with:

pip install -e .[dev]
pytest -q

Notes

  • Stable and unique test_id values are required.
  • For deterministic CI runs, configure an explicit approvals notebook path.
  • Works well with Papermill-driven notebook execution.

License

Apache License 2.0. See LICENSE.

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

nbapproval-0.3.0.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

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

nbapproval-0.3.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file nbapproval-0.3.0.tar.gz.

File metadata

  • Download URL: nbapproval-0.3.0.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for nbapproval-0.3.0.tar.gz
Algorithm Hash digest
SHA256 e8d8285ba60cb8c76a6d152ec324fbe471125bd0065b08507d7f5f9732b4cab3
MD5 e8e5718f08c805307b27774d8ea078f6
BLAKE2b-256 cb850cc92b00d7b535d02d60036ce1af6b078ab29fdc3145d22fb6e1e8cc1816

See more details on using hashes here.

Provenance

The following attestation bundles were made for nbapproval-0.3.0.tar.gz:

Publisher: publish.yml on wiki3-ai/nbapproval

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nbapproval-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: nbapproval-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for nbapproval-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a187e405318f740bae22fe31359a31e84e049409f3d89ed31a55b2a200d8a97b
MD5 95766b2f711a9af1d3e8fd86f41138b8
BLAKE2b-256 c81c6b57c6d2a8dc18eb093200c6389f2864e882676868d671d6c4345cf0947e

See more details on using hashes here.

Provenance

The following attestation bundles were made for nbapproval-0.3.0-py3-none-any.whl:

Publisher: publish.yml on wiki3-ai/nbapproval

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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