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

# pytest-ditto-polars

A [pytest-ditto](https://github.com/owlowlyowl/pytest-ditto) plugin for polars DataFrame snapshots.

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

## Installation

```bash
pip install "pytest-ditto[polars]"
```

## Marks

- `@ditto.polars.parquet`
- `@ditto.polars.ipc`
- `@ditto.polars.csv`
- `@ditto.polars.ndjson`

Each mark is shorthand for `@ditto.record("<name>")`.

**Use `@ditto.polars.parquet` or `@ditto.polars.ipc`**: CSV and NDJSON infer
types again on load. See the format notes in the documentation.

## Usage

```python
import polars as pl
import polars.testing

import ditto


def awesome_fn_to_test(df: pl.DataFrame) -> pl.DataFrame:
    return df.with_columns(pl.col("a") * 2)


# The following test uses polars.DataFrame.write_parquet to write the data snapshot
# to the `.ditto` directory with filename:
# `<module>.test_fn_with_parquet_dataframe_snapshot@ab_dataframe~<hash>.polars.parquet`.


@ditto.polars.parquet
def test_fn_with_parquet_dataframe_snapshot(snapshot):
    input_data = pl.DataFrame({"a": [1, 2, 3], "b": [4, 5, 9]})
    result = awesome_fn_to_test(input_data)
    pl.testing.assert_frame_equal(result, snapshot(result, key="ab_dataframe"))
```
