Metadata-Version: 2.5
Name: pytest-ditto-pickle
Version: 2.0.0b1
Summary: pytest-ditto plugin for pickle snapshots.
Project-URL: Homepage, https://github.com/owlowlyowl/pytest-ditto
Project-URL: Source, https://github.com/owlowlyowl/pytest-ditto/tree/main/plugins/pickle
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: pickle,pytest,snapshot,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: pytest-ditto<3,>=2.0.0b1
Description-Content-Type: text/markdown

# pytest-ditto-pickle

Extension plugin for [`pytest-ditto`](https://github.com/owlowlyowl/pytest-ditto) that records snapshots with Python's `pickle`.

> [!WARNING]
> Loading pickle data can execute arbitrary code. Only load snapshots you
> trust, and never load a `.pkl` snapshot from an untrusted source, such as a
> pull request from someone you don't know. Review changes to `.pkl` files as
> carefully as changes to code.

pytest-ditto records snapshots as strict JSON by default. Use pickle only when
a value can't be represented in JSON, or YAML, or one of the other recorders,
and you accept the risk above.

## Installation
```bash
pip install pytest-ditto-pickle
```

pytest-ditto has no `pickle` extra: install this package by name, deliberately.

## Usage

Select the recorder explicitly on each test, with `@ditto.pickle` or its
long form, `@ditto.record("pickle")`:

```python
import datetime

import ditto


@ditto.pickle
def test_schedule(snapshot):
    schedule = {"days": {"mon", "wed"}, "start": datetime.time(9, 30)}
    assert snapshot(schedule, key="schedule") == schedule
```

## Snapshots from pytest-ditto 1.x

pytest-ditto 1.x used pickle by default and saved snapshots with the `.pkl`
extension. This recorder keeps that extension and file format, so a 1.x
`.pkl` file loads unchanged.

pytest-ditto 2.0 names snapshot files differently, though, so 2.0 won't find a
1.x file where 1.x left it. See the pytest-ditto upgrade guide for the new
names.
