Skip to main content

pandas integration for inline-snapshot

Project description

ci Docs pypi version Python Versions PyPI - Downloads coverage GitHub Sponsors

Installation

pip install inline-snapshot-pandas

Usage

This packages provides special assert_(frame|series|index)_equal implementation which accept a snapshot as second argument.

from pandas import DataFrame
from inline_snapshot_pandas import assert_frame_equal
from inline_snapshot import snapshot


def test_assert_equal():
    df = DataFrame({"col0": [1, 2]})

    assert_frame_equal(df, snapshot())
pytest --inline-snapshot=create
from pandas import DataFrame
from inline_snapshot_pandas import assert_frame_equal
from inline_snapshot import snapshot


def test_assert_equal():
    df = DataFrame({"col0": [1, 2]})

    assert_frame_equal(
        df,
        snapshot(DataFrame([{"col0": 1}, {"col0": 2}])),
    )

Another way to use it is to call setup() in conftest.py, which replaces the implementation which pandas uses.

from inline_snapshot_pandas import setup

setup()

You can then use implementation from pandas with snapshots.

from pandas import DataFrame
from pandas.testing import assert_frame_equal
from inline_snapshot import snapshot


def test_assert_equal():
    df = DataFrame({"col0": [1, 2], "col1": [1, 5j], "col3": ["a", "b"]})

    # the second argument can be a snapshot
    assert_frame_equal(
        df,
        snapshot(
            DataFrame(
                [
                    {"col0": 1, "col1": (1 + 0j), "col3": "a"},
                    {"col0": 2, "col1": 5j, "col3": "b"},
                ]
            )
        ),
    )

Issues

If you encounter any problems, please report an issue along with a detailed description.

License

Distributed under the terms of the MIT license, "inline-snapshot-pandas" is free and open source software.

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

inline_snapshot_pandas-0.2.0.tar.gz (118.9 kB view details)

Uploaded Source

Built Distribution

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

inline_snapshot_pandas-0.2.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file inline_snapshot_pandas-0.2.0.tar.gz.

File metadata

  • Download URL: inline_snapshot_pandas-0.2.0.tar.gz
  • Upload date:
  • Size: 118.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for inline_snapshot_pandas-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d782316c885961be356f3d378b2e9c7da25c6814ea8c4e93d04d425b64f5bb19
MD5 68f8f17a9d39d5d97cc477e383cb8d0b
BLAKE2b-256 e65a5b82c36a2e304d0c08b9e54456b9f7d05c637f64ec6746cb464e4d8db312

See more details on using hashes here.

File details

Details for the file inline_snapshot_pandas-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: inline_snapshot_pandas-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for inline_snapshot_pandas-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 575c59065a05b648667864e7dcf3f0104e0553d5cdd4f941c93f5de057392c21
MD5 d77a9bb29aa6121495bdd45e9bf73f3f
BLAKE2b-256 e75ca732bfa9032055a1286b9377e0417c28301c138db5b77bb127cc98dc2bfd

See more details on using hashes here.

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