pandas integration for inline-snapshot
Project description
Installation
This project is currently only available for insiders, which mean that you can get access to it if you sponsor me. You should then have access to this repository.
pip install git+ssh://git@github.com:15r10nk-insiders/inline-snapshot-pandas.git@insiders
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file inline_snapshot_pandas-0.0.1.tar.gz
.
File metadata
- Download URL: inline_snapshot_pandas-0.0.1.tar.gz
- Upload date:
- Size: 27.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c126d13626048e7d9b8c2512787e38f0f67d1f655b42901d5ff971994d3d200d |
|
MD5 | de787e0f1366c2a5d5ce195ea82922f5 |
|
BLAKE2b-256 | 9b5fb9b59142c9114f74460bf6adc7750b4534e4f7f06fe373b6dc9daadb44fa |
File details
Details for the file inline_snapshot_pandas-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: inline_snapshot_pandas-0.0.1-py3-none-any.whl
- Upload date:
- Size: 2.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2345c6814363af073f4e19f307997692b7548185a7af5d124c58ea7ae4c6a92 |
|
MD5 | 6707f172b0e2ce494ad6d033bdca6144 |
|
BLAKE2b-256 | 233bab6bb40045e2407394ed242da712cc7678d4388e17a82b65b83406f42472 |