Metadata-Version: 2.5
Name: pytest-ditto
Version: 2.0.0
Summary: Snapshot testing pytest plugin with minimal ceremony and flexible recorders.
Author-email: Lachlan Taylor <95459213+owlowlyowl@users.noreply.github.com>
Maintainer-email: Lachlan Taylor <95459213+owlowlyowl@users.noreply.github.com>
License-Expression: MIT
License-File: LICENSE
Keywords: pytest,testing
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: Pytest
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.12
Requires-Dist: click
Requires-Dist: fsspec
Requires-Dist: msgspec>=0.18
Requires-Dist: pytest>=8.3
Requires-Dist: pyyaml
Requires-Dist: rich
Provides-Extra: dev
Requires-Dist: hatch-vcs>=0.4.0; extra == 'dev'
Requires-Dist: hatch>=1.9.4; extra == 'dev'
Requires-Dist: pre-commit; extra == 'dev'
Provides-Extra: pandas
Requires-Dist: pytest-ditto-pandas; extra == 'pandas'
Provides-Extra: polars
Requires-Dist: pytest-ditto-polars; extra == 'polars'
Provides-Extra: pyarrow
Requires-Dist: pytest-ditto-pyarrow; extra == 'pyarrow'
Description-Content-Type: text/markdown

# pytest-ditto

[![PyPI version](https://badge.fury.io/py/pytest-ditto.svg)](https://badge.fury.io/py/pytest-ditto)
[![Continuous Integration](https://github.com/owlowlyowl/pytest-ditto/actions/workflows/ci.yml/badge.svg)](https://github.com/owlowlyowl/pytest-ditto/actions/workflows/ci.yml)
[![Documentation](https://github.com/owlowlyowl/pytest-ditto/actions/workflows/docs.yml/badge.svg)](https://owlowlyowl.github.io/pytest-ditto/)

Snapshot testing pytest plugin with minimal ceremony and flexible recorders.

**[📖 Documentation](https://owlowlyowl.github.io/pytest-ditto/)**

## Features

- **Snapshot fixture**: record a test's output once, then fail when it changes
- **Recorders**: strict JSON by default, built-in YAML, and plugins for pandas,
  polars, PyArrow and pickle
- **Storage backends**: keep snapshots next to your tests, on S3 or anywhere
  fsspec reaches, or in your own backend for a database such as Redis
- **Lock file**: a committed `ditto.lock` records every snapshot, so CI fails on
  missing or stale ones
- **CLI**: update, verify, prune, list and inspect snapshots

## Quick Start

```bash
pip install pytest-ditto
```

<!-- test: passes -->
```python
def summarise(prices):
    return {"count": len(prices), "total": sum(prices)}


def test_summarise(snapshot):
    result = summarise([3, 4.5])
    assert result == snapshot(result, key="summary")
```

The first run stores the result as a snapshot. Every later run compares the
result with it, and fails if it has changed. Run `ditto verify` in CI so a
missing snapshot fails instead of being recorded again.

Upgrading from 1.x? Read
[Upgrading to 2.0](https://owlowlyowl.github.io/pytest-ditto/upgrading/) first:
2.0 doesn't find snapshots recorded by 1.x.

## Documentation

Full documentation is at
**[owlowlyowl.github.io/pytest-ditto](https://owlowlyowl.github.io/pytest-ditto/)**:

- [Getting Started](https://owlowlyowl.github.io/pytest-ditto/getting-started/)
- [Recorders](https://owlowlyowl.github.io/pytest-ditto/guides/recorders/)
- [Running in CI](https://owlowlyowl.github.io/pytest-ditto/guides/ci/)
- [Configuration](https://owlowlyowl.github.io/pytest-ditto/reference/configuration/)
- [CLI Reference](https://owlowlyowl.github.io/pytest-ditto/cli/)

## Examples

See [examples/](https://github.com/owlowlyowl/pytest-ditto/tree/main/examples)
for self-contained local, PostgreSQL, Redis and DuckDB backends.
