<!-- -8<- [start:Header] -->
<p align="center">
<a href="https://15r10nk.github.io/inline-snapshot/">
<img src="https://raw.githubusercontent.com/15r10nk/inline-snapshot/main/docs/assets/logo.svg" width="500" alt="inline-snapshot">
</a>
</p>
![ci](https://github.com/15r10nk/inline-snapshot/actions/workflows/ci.yml/badge.svg?branch=main)
[![Docs](https://img.shields.io/badge/docs-mkdocs-green)](https://15r10nk.github.io/inline-snapshot/)
[![pypi version](https://img.shields.io/pypi/v/inline-snapshot.svg)](https://pypi.org/project/inline-snapshot/)
![Python Versions](https://img.shields.io/pypi/pyversions/inline-snapshot)
![PyPI - Downloads](https://img.shields.io/pypi/dw/inline-snapshot)
[![coverage](https://img.shields.io/badge/coverage-100%25-blue)](https://15r10nk.github.io/inline-snapshot/contributing/#coverage)
[![GitHub Sponsors](https://img.shields.io/github/sponsors/15r10nk)](https://github.com/sponsors/15r10nk)
<!-- -8<- [end:Header] -->
## Installation
You can install "inline-snapshot" via [pip](https://pypi.org/project/pip/):
``` bash
pip install inline-snapshot
```
## Key Features
- **Intuitive Semantics:** `snapshot(x)` mirrors `x` for easy understanding.
- **Versatile Comparison Support:** Equipped with `x == snapshot(...)`, `x <= snapshot(...)`, `x in snapshot(...)`, and `snapshot(...)[key]`.
- **Enhanced Control Flags:** Utilize various [flags](https://15r10nk.github.io/inline-snapshot/pytest/) for precise control of which snapshots you want to change.
- **Preserved Black Formatting:** Retains formatting consistency with Black formatting.
- **External File Storage:** Store snapshots externally using `outsource(data)`.
- **Seamless Pytest Integration:** Integrated seamlessly with pytest for effortless testing.
- **Comprehensive Documentation:** Access detailed [documentation](https://15r10nk.github.io/inline-snapshot/) for complete guidance.
## Usage
You can use `snapshot()` instead of the value which you want to compare with.
<!-- inline-snapshot: outcome-errors=1 outcome-passed=1 -->
```python
from inline_snapshot import snapshot
def test_something():
assert 1548 * 18489 == snapshot()
```
You can now run the tests and record the correct values.
```
$ pytest --inline-snapshot=create
```
<!-- inline-snapshot: create -->
```python
from inline_snapshot import snapshot
def test_something():
assert 1548 * 18489 == snapshot(28620972)
```
inline-snapshot provides more advanced features like:
<!-- inline-snapshot: fix create trim this -->
```python
from inline_snapshot import snapshot, outsource, external
def test_something():
for number in range(5):
# testing for numeric limits
assert number <= snapshot(4)
assert number >= snapshot(0)
for c in "hello world":
# test if something is part of a set
assert c in snapshot(["h", "e", "l", "o", " ", "w", "r", "d"])
s = snapshot(
{
0: {"square": 0, "pow_of_two": False},
1: {"square": 1, "pow_of_two": True},
2: {"square": 4, "pow_of_two": True},
3: {"square": 9, "pow_of_two": False},
4: {"square": 16, "pow_of_two": True},
}
)
for number in range(5):
# create sub-snapshots at runtime
assert s[number]["square"] == number**2
assert s[number]["pow_of_two"] == (
(number & (number - 1) == 0) and number != 0
)
assert outsource("large string\n" * 1000) == snapshot(
external("8bf10bdf2c30*.txt")
)
```
<!-- -8<- [start:Feedback] -->
## Feedback
inline-snapshot provides some advanced ways to work with snapshots.
I would like to know how these features are used to further improve this small library.
Let me know if you've found interesting use cases for this library via [twitter](https://twitter.com/15r10nk), [fosstodon](https://fosstodon.org/deck/@15r10nk) or in the github [discussions](https://github.com/15r10nk/inline-snapshot/discussions/new?category=show-and-tell).
## Sponsors
I would like to thank my sponsors. Without them, I would not be able to invest so much time in my projects.
### Bronze sponsor 🥉
<p align="center">
<a href="https://pydantic.dev/">
<img src="docs/assets/sponsors/pydantic.png" alt="pydantic" width="300"/>
</a>
</p>
## Issues
If you encounter any problems, please [report an issue](https://github.com/15r10nk/inline-snapshot/issues) along with a detailed description.
<!-- -8<- [end:Feedback] -->
## License
Distributed under the terms of the [MIT](http://opensource.org/licenses/MIT) license, "inline-snapshot" is free and open source software.
Raw data
{
"_id": null,
"home_page": "https://github.com/15r10nk/inline-snapshots",
"name": "inline-snapshot",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "pytest, testing, snapshot, approval, golden-master",
"author": "Frank Hoffmann",
"author_email": "15r10nk@polarbit.de",
"download_url": "https://files.pythonhosted.org/packages/98/f1/b2aa583fc65997e13827e8f93be29fe6ba4a3aa0cd93852eb23f75647ffd/inline_snapshot-0.8.1.tar.gz",
"platform": null,
"description": "<!-- -8<- [start:Header] -->\n\n<p align=\"center\">\n <a href=\"https://15r10nk.github.io/inline-snapshot/\">\n <img src=\"https://raw.githubusercontent.com/15r10nk/inline-snapshot/main/docs/assets/logo.svg\" width=\"500\" alt=\"inline-snapshot\">\n </a>\n</p>\n\n![ci](https://github.com/15r10nk/inline-snapshot/actions/workflows/ci.yml/badge.svg?branch=main)\n[![Docs](https://img.shields.io/badge/docs-mkdocs-green)](https://15r10nk.github.io/inline-snapshot/)\n[![pypi version](https://img.shields.io/pypi/v/inline-snapshot.svg)](https://pypi.org/project/inline-snapshot/)\n![Python Versions](https://img.shields.io/pypi/pyversions/inline-snapshot)\n![PyPI - Downloads](https://img.shields.io/pypi/dw/inline-snapshot)\n[![coverage](https://img.shields.io/badge/coverage-100%25-blue)](https://15r10nk.github.io/inline-snapshot/contributing/#coverage)\n[![GitHub Sponsors](https://img.shields.io/github/sponsors/15r10nk)](https://github.com/sponsors/15r10nk)\n\n<!-- -8<- [end:Header] -->\n\n## Installation\n\nYou can install \"inline-snapshot\" via [pip](https://pypi.org/project/pip/):\n\n``` bash\npip install inline-snapshot\n```\n\n## Key Features\n\n- **Intuitive Semantics:** `snapshot(x)` mirrors `x` for easy understanding.\n- **Versatile Comparison Support:** Equipped with `x == snapshot(...)`, `x <= snapshot(...)`, `x in snapshot(...)`, and `snapshot(...)[key]`.\n- **Enhanced Control Flags:** Utilize various [flags](https://15r10nk.github.io/inline-snapshot/pytest/) for precise control of which snapshots you want to change.\n- **Preserved Black Formatting:** Retains formatting consistency with Black formatting.\n- **External File Storage:** Store snapshots externally using `outsource(data)`.\n- **Seamless Pytest Integration:** Integrated seamlessly with pytest for effortless testing.\n- **Comprehensive Documentation:** Access detailed [documentation](https://15r10nk.github.io/inline-snapshot/) for complete guidance.\n\n\n## Usage\n\nYou can use `snapshot()` instead of the value which you want to compare with.\n\n<!-- inline-snapshot: outcome-errors=1 outcome-passed=1 -->\n```python\nfrom inline_snapshot import snapshot\n\n\ndef test_something():\n assert 1548 * 18489 == snapshot()\n```\n\nYou can now run the tests and record the correct values.\n\n```\n$ pytest --inline-snapshot=create\n```\n\n<!-- inline-snapshot: create -->\n```python\nfrom inline_snapshot import snapshot\n\n\ndef test_something():\n assert 1548 * 18489 == snapshot(28620972)\n```\n\ninline-snapshot provides more advanced features like:\n\n<!-- inline-snapshot: fix create trim this -->\n```python\nfrom inline_snapshot import snapshot, outsource, external\n\n\ndef test_something():\n for number in range(5):\n # testing for numeric limits\n assert number <= snapshot(4)\n assert number >= snapshot(0)\n\n for c in \"hello world\":\n # test if something is part of a set\n assert c in snapshot([\"h\", \"e\", \"l\", \"o\", \" \", \"w\", \"r\", \"d\"])\n\n s = snapshot(\n {\n 0: {\"square\": 0, \"pow_of_two\": False},\n 1: {\"square\": 1, \"pow_of_two\": True},\n 2: {\"square\": 4, \"pow_of_two\": True},\n 3: {\"square\": 9, \"pow_of_two\": False},\n 4: {\"square\": 16, \"pow_of_two\": True},\n }\n )\n\n for number in range(5):\n # create sub-snapshots at runtime\n assert s[number][\"square\"] == number**2\n assert s[number][\"pow_of_two\"] == (\n (number & (number - 1) == 0) and number != 0\n )\n\n assert outsource(\"large string\\n\" * 1000) == snapshot(\n external(\"8bf10bdf2c30*.txt\")\n )\n```\n\n<!-- -8<- [start:Feedback] -->\n## Feedback\n\ninline-snapshot provides some advanced ways to work with snapshots.\n\nI would like to know how these features are used to further improve this small library.\nLet me know if you've found interesting use cases for this library via [twitter](https://twitter.com/15r10nk), [fosstodon](https://fosstodon.org/deck/@15r10nk) or in the github [discussions](https://github.com/15r10nk/inline-snapshot/discussions/new?category=show-and-tell).\n\n## Sponsors\n\nI would like to thank my sponsors. Without them, I would not be able to invest so much time in my projects.\n\n### Bronze sponsor \ud83e\udd49\n\n<p align=\"center\">\n <a href=\"https://pydantic.dev/\">\n <img src=\"docs/assets/sponsors/pydantic.png\" alt=\"pydantic\" width=\"300\"/>\n </a>\n</p>\n\n## Issues\n\nIf you encounter any problems, please [report an issue](https://github.com/15r10nk/inline-snapshot/issues) along with a detailed description.\n<!-- -8<- [end:Feedback] -->\n\n## License\n\nDistributed under the terms of the [MIT](http://opensource.org/licenses/MIT) license, \"inline-snapshot\" is free and open source software.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "golden master/snapshot/approval testing library which puts the values right into your source code",
"version": "0.8.1",
"project_urls": {
"Changelog": "https://15r10nk.github.io/inline-snapshot/changelog/",
"Discussions": "https://15r10nk.github.io/inline-snapshot/discussions",
"Documentation": "https://15r10nk.github.io/inline-snapshot",
"Funding": "https://github.com/sponsors/15r10nk",
"Homepage": "https://15r10nk.github.io/inline-snapshot",
"Issues": "https://github.com/15r10nk/inline-snapshots/issues",
"Repository": "https://github.com/15r10nk/inline-snapshot/"
},
"split_keywords": [
"pytest",
" testing",
" snapshot",
" approval",
" golden-master"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "163a602cb902ee0121a7bd96d8dace01699e69f381f3b13983e2cd2e2def4952",
"md5": "af9693be5a26b41675afbf6dfd71783c",
"sha256": "6002971f1c609e9e6b29e7bd92e04f38eec08211386f08e87ac38b12b2dbe8d0"
},
"downloads": -1,
"filename": "inline_snapshot-0.8.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "af9693be5a26b41675afbf6dfd71783c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 21461,
"upload_time": "2024-04-22T07:02:05",
"upload_time_iso_8601": "2024-04-22T07:02:05.920094Z",
"url": "https://files.pythonhosted.org/packages/16/3a/602cb902ee0121a7bd96d8dace01699e69f381f3b13983e2cd2e2def4952/inline_snapshot-0.8.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "98f1b2aa583fc65997e13827e8f93be29fe6ba4a3aa0cd93852eb23f75647ffd",
"md5": "0921ef01f2fc5d3024c6e0829ba745af",
"sha256": "f3bcec3def5f511c2b2523d615d04a5e68a3ed74ca7f89eca2f8475e9545e5bc"
},
"downloads": -1,
"filename": "inline_snapshot-0.8.1.tar.gz",
"has_sig": false,
"md5_digest": "0921ef01f2fc5d3024c6e0829ba745af",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 19511,
"upload_time": "2024-04-22T07:02:07",
"upload_time_iso_8601": "2024-04-22T07:02:07.905786Z",
"url": "https://files.pythonhosted.org/packages/98/f1/b2aa583fc65997e13827e8f93be29fe6ba4a3aa0cd93852eb23f75647ffd/inline_snapshot-0.8.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-22 07:02:07",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "15r10nk",
"github_project": "inline-snapshots",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "inline-snapshot"
}