Skip to main content

pytest-ditto plugin for pyarrow table snapshots.

Project description

pytest-ditto-pyarrow

Extension plugin for pytest-ditto for pyarrow table snapshots.

Use the following marks for their associated recorder:

  • @ditto.pyarrow.parquet
  • @ditto.pyarrow.feather
  • @ditto.pyarrow.csv

Installation

pip install pytest-ditto[pyarrow]

Usage

The following test example tests the result of fn hasn't changed by comparing against a saved snapshot of the result. This snapshot is taken the first time the test is run; hence, the initial run is not a proper test run. Subsequent test runs are compared against the saved result.

  • The fixture, table is a pyarrow.Table and is the argument to the function under test, fn.
  • fn transforms the data and the test asserts the result of this function in unchanged compared to the initial, hopefully validated, result.
  • The output format of the snapshot is parquet as defined by the @ditto.pyarrow.parquet mark.
import pyarrow as pa
import pyarrow.compute as pc
import ditto
import pytest


@pytest.fixture
def table() -> pa.Table:
    return pa.table(
        [
            [1, 2, 3, 4],
            [4.5, 5.2, 6.8, 3.5],
            [7, 8.5, None, None],
            [True, False, True, True],
            ["a", "b", "c", "x"],
        ],
        names=list("abcde"),
    )


def fn(x: pa.Table):
    even_filter = (pc.bit_wise_and(pc.field("a"), pc.scalar(1)) == pc.scalar(0))
    return x.filter(even_filter)


@ditto.pyarrow.parquet
def test_fn_with_pyarrow_parquet_snapshot(snapshot, table):
    result = fn(table)
    assert result.equals(snapshot(result, key="filtered"))

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

pytest_ditto_pyarrow-0.1.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

pytest_ditto_pyarrow-0.1.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file pytest_ditto_pyarrow-0.1.0.tar.gz.

File metadata

  • Download URL: pytest_ditto_pyarrow-0.1.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pytest_ditto_pyarrow-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0f9465a6ba05f028a906ddfb2f2f47dbad74fd879b0d6cb301c847c0b8e138f3
MD5 cb8b574d29a49cc00b1215943693afb3
BLAKE2b-256 ea4e89f48b9d4f0615c9b759a2ccec4626f2de914e655544e0e5ea1bd89e6768

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_ditto_pyarrow-0.1.0.tar.gz:

Publisher: release.yml on owlowlyowl/pytest-ditto-pyarrow

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

File details

Details for the file pytest_ditto_pyarrow-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_ditto_pyarrow-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4d4a27fc1c6b36a98e3181c68ed07e284f10f2ed280576aa810511f1dbe006f1
MD5 a8cc70bc7c5894ab50b8cfb889387be7
BLAKE2b-256 ed89d3a8cd09873dd57ae90d0751db4f742e94e997464f4f01ef70c94ef81bae

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_ditto_pyarrow-0.1.0-py3-none-any.whl:

Publisher: release.yml on owlowlyowl/pytest-ditto-pyarrow

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