pytest-ditto-pandas
pytest-ditto plugin for pandas snapshots.
@ditto Marks
If the default recorder, pickle, isn't appropriate a different recorder can be
specified per test using ditto marks — customised pytest mark decorators.
Usage
pd.DataFrame
import pandas as pd
import ditto
def awesome_fn_to_test(df: pd.DataFrame):
df.loc[:, "a"] *= 2
return df
# The following test uses pandas.DataFrame.to_parquet to write the data snapshot to the
# `.ditto` directory with filename:
# `test_fn_with_parquet_dataframe_snapshot@ab_dataframe.pandas.parquet`.
@ditto.pandas.parquet
def test_fn_with_parquet_dataframe_snapshot(snapshot):
input_data = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 9]})
result = awesome_fn_to_test(input_data)
pd.testing.assert_frame_equal(result, snapshot(result, key="ab_dataframe"))
# The following test uses pandas.DataFrame.to_json(orient="table") to write the data
# snapshot to the `.ditto` directory with filename:
# `test_fn_with_json_dataframe_snapshot@ab_dataframe.pandas.json`.
@ditto.pandas.json
def test_fn_with_json_dataframe_snapshot(snapshot):
input_data = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 9]})
result = awesome_fn_to_test(input_data)
pd.testing.assert_frame_equal(result, snapshot(result, key="ab_dataframe"))
Format notes
| Format | Index preserved | dtype preserved |
|---|---|---|
| parquet | yes | yes |
| json | yes | yes |
| csv | single-level numeric or string only (see below) | no |
The CSV recorder does not preserve index type metadata. Supported index types
for round-trip are single-level numeric (note: RangeIndex is read back as
Int64) and string. DatetimeIndex, PeriodIndex, CategoricalIndex, and
MultiIndex are not supported — use @ditto.pandas.parquet or
@ditto.pandas.json for DataFrames with these index types.
When comparing a CSV snapshot with pd.testing.assert_frame_equal, pass
check_index_type=False to account for the RangeIndex → Int64 conversion.
Metadata
Release files for pytest-ditto-pandas 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytest_ditto_pandas-0.1.2.tar.gz | 4.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytest_ditto_pandas-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.5 kB
Release files / pytest_ditto_pandas-0.1.2.tar.gz
| Download URL | pytest_ditto_pandas-0.1.2.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7f10b84576a1533ca366ac2ec3bc2b8f1b8f10a0238d48b16dfe966283a273b7
|
|
BLAKE2b-256 checksum How to use checksums |
44e1f929e5bfdc3fcc6e7c3aa7f7224906bdad5003536296b57c4284522b1fbe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.
Transparency logRelease files / pytest_ditto_pandas-0.1.2-py3-none-any.whl
| Download URL | pytest_ditto_pandas-0.1.2-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c9196c5a8504a0d8c031a64bcc0dc6f7dc460f15568be69e2584d93a88ddde0f
|
|
BLAKE2b-256 checksum How to use checksums |
e251d64c53e3cee9e02d39973602f3cbbdd94d3efdc6ab92e3cf1343eb18cdae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.
Transparency log