Name | pytest-ditto-pandas JSON |
Version |
0.0.1
JSON |
| download |
home_page | None |
Summary | pytest-ditto plugin for pandas snapshots. |
upload_time | 2024-05-29 12:49:10 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | None |
keywords |
pytest
testing
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# pytest-ditto-pandas
[![PyPI version](https://badge.fury.io/py/pytest-ditto-pandas.svg)](https://badge.fury.io/py/pytest-ditto-pandas)
[![Continuous Integration](https://github.com/owlowlyowl/pytest-ditto-pandas/actions/workflows/ci.yml/badge.svg)](https://github.com/owlowlyowl/pytest-ditto-pandas/actions/workflows/ci.yml)
`pytest-ditto` plugin for pandas snapshots.
## @ditto Marks
If the default persistence format, `pickle`, isn't appropriate different formats can be
specified per test by using `ditto` marks - customised `pytest` mark decorators.
## Usage
### `pd.DataFrame`
```python
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"))
```
Raw data
{
"_id": null,
"home_page": null,
"name": "pytest-ditto-pandas",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "Lachlan Taylor <lachlanbtaylor@proton.me>",
"keywords": "pytest, testing",
"author": null,
"author_email": "Lachlan Taylor <lachlanbtaylor@proton.me>",
"download_url": "https://files.pythonhosted.org/packages/05/72/451ded961ce7b3bd1ebda6b36e6f197e1b726277c0fdd4f2aa600f201467/pytest_ditto_pandas-0.0.1.tar.gz",
"platform": null,
"description": "# pytest-ditto-pandas\n[![PyPI version](https://badge.fury.io/py/pytest-ditto-pandas.svg)](https://badge.fury.io/py/pytest-ditto-pandas)\n[![Continuous Integration](https://github.com/owlowlyowl/pytest-ditto-pandas/actions/workflows/ci.yml/badge.svg)](https://github.com/owlowlyowl/pytest-ditto-pandas/actions/workflows/ci.yml)\n\n`pytest-ditto` plugin for pandas snapshots.\n\n## @ditto Marks\nIf the default persistence format, `pickle`, isn't appropriate different formats can be\nspecified per test by using `ditto` marks - customised `pytest` mark decorators.\n\n\n## Usage\n\n### `pd.DataFrame`\n\n```python\nimport pandas as pd\n\nimport ditto\n\n\ndef awesome_fn_to_test(df: pd.DataFrame):\n df.loc[:, \"a\"] *= 2\n return df\n\n\n# The following test uses pandas.DataFrame.to_parquet to write the data snapshot to the\n# `.ditto` directory with filename:\n# `test_fn_with_parquet_dataframe_snapshot@ab_dataframe.pandas.parquet`.\n\n@ditto.pandas.parquet\ndef test_fn_with_parquet_dataframe_snapshot(snapshot):\n input_data = pd.DataFrame({\"a\": [1, 2, 3], \"b\": [4, 5, 9]})\n result = awesome_fn_to_test(input_data)\n pd.testing.assert_frame_equal(result, snapshot(result, key=\"ab_dataframe\"))\n\n\n# The following test uses pandas.DataFrame.to_json(orient=\"table\") to write the data\n# snapshot to the `.ditto` directory with filename:\n# `test_fn_with_json_dataframe_snapshot@ab_dataframe.pandas.json`.\n\n@ditto.pandas.json\ndef test_fn_with_json_dataframe_snapshot(snapshot):\n input_data = pd.DataFrame({\"a\": [1, 2, 3], \"b\": [4, 5, 9]})\n result = awesome_fn_to_test(input_data)\n pd.testing.assert_frame_equal(result, snapshot(result, key=\"ab_dataframe\"))\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "pytest-ditto plugin for pandas snapshots.",
"version": "0.0.1",
"project_urls": null,
"split_keywords": [
"pytest",
" testing"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "df2f3ce02e0d0d8094c4cc45cae316c215aacc27db052a5073f5d712587b7098",
"md5": "a5568f969eb5f33525b4605b03412bc6",
"sha256": "65bed0703482495a76c44d6f0c531eae61bef01b75d750f021ac027ac259761a"
},
"downloads": -1,
"filename": "pytest_ditto_pandas-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a5568f969eb5f33525b4605b03412bc6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 4071,
"upload_time": "2024-05-29T12:49:08",
"upload_time_iso_8601": "2024-05-29T12:49:08.962550Z",
"url": "https://files.pythonhosted.org/packages/df/2f/3ce02e0d0d8094c4cc45cae316c215aacc27db052a5073f5d712587b7098/pytest_ditto_pandas-0.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0572451ded961ce7b3bd1ebda6b36e6f197e1b726277c0fdd4f2aa600f201467",
"md5": "6bf52921a5aed9de50a2dfc65a14d70b",
"sha256": "6c3d6d062ac42f99d7dc8663c9ec842f840c86837cc06e47ba03b6e986d133c5"
},
"downloads": -1,
"filename": "pytest_ditto_pandas-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "6bf52921a5aed9de50a2dfc65a14d70b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 3773,
"upload_time": "2024-05-29T12:49:10",
"upload_time_iso_8601": "2024-05-29T12:49:10.433534Z",
"url": "https://files.pythonhosted.org/packages/05/72/451ded961ce7b3bd1ebda6b36e6f197e1b726277c0fdd4f2aa600f201467/pytest_ditto_pandas-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-29 12:49:10",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "pytest-ditto-pandas"
}