{"id":13501196,"url":"https://github.com/15r10nk/inline-snapshot","last_synced_at":"2026-03-01T08:02:46.984Z","repository":{"id":57727980,"uuid":"517749777","full_name":"15r10nk/inline-snapshot","owner":"15r10nk","description":"create and update inline snapshots in your python tests","archived":false,"fork":false,"pushed_at":"2025-05-12T23:06:33.000Z","size":5984,"stargazers_count":488,"open_issues_count":18,"forks_count":13,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-05-12T23:34:07.842Z","etag":null,"topics":["approval-testing","golden-master","pytest","python","snapshot-testing","testing"],"latest_commit_sha":null,"homepage":"https://15r10nk.github.io/inline-snapshot/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/15r10nk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"15r10nk"}},"created_at":"2022-07-25T16:57:35.000Z","updated_at":"2025-05-11T16:13:51.000Z","dependencies_parsed_at":"2024-01-01T23:27:58.023Z","dependency_job_id":"c9132fec-0a81-4611-8ac4-e1081d1a0ab6","html_url":"https://github.com/15r10nk/inline-snapshot","commit_stats":{"total_commits":169,"total_committers":7,"mean_commits":"24.142857142857142","dds":0.09467455621301779,"last_synced_commit":"0bc0e8b7f72b83c7f1beaa32d5ba0a008a875e90"},"previous_names":["15r10nk/inline-snapshots"],"tags_count":96,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/15r10nk%2Finline-snapshot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/15r10nk%2Finline-snapshot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/15r10nk%2Finline-snapshot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/15r10nk%2Finline-snapshot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/15r10nk","download_url":"https://codeload.github.com/15r10nk/inline-snapshot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253843167,"owners_count":21972867,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["approval-testing","golden-master","pytest","python","snapshot-testing","testing"],"created_at":"2024-07-31T22:01:28.868Z","updated_at":"2026-03-01T08:02:46.944Z","avatar_url":"https://github.com/15r10nk.png","language":"Python","funding_links":["https://github.com/sponsors/15r10nk"],"categories":["Python","🧪 Testing"],"sub_categories":["📰 Blogs"],"readme":"\u003c!-- -8\u003c- [start:Header] --\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://15r10nk.github.io/inline-snapshot/latest/\"\u003e\n    \u003cimg src=\"docs/assets/logo.svg\" width=\"500\" alt=\"inline-snapshot\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\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/latest/)\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)](https://pypacktrends.com/?packages=inline-snapshot\u0026time_range=2years)\n[![coverage](https://img.shields.io/badge/coverage-100%25-blue)](https://15r10nk.github.io/inline-snapshot/latest/contributing/#coverage)\n[![GitHub Sponsors](https://img.shields.io/github/sponsors/15r10nk)](https://github.com/sponsors/15r10nk)\n[![Discord](https://img.shields.io/discord/1435889192143159346)](https://discord.gg/bnSwDaaPTa)\n\n\u003c!-- -8\u003c- [end:Header] --\u003e\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\n## Key Features\n\n- **support for normal assertions:** inline-snapshot can now also fix normal assertions which do not use `snapshot()` like:\n\n    ``` python\n    assert 1 + 1 == 3\n    ```\n\n    You can learn [here](https://15r10nk.github.io/inline-snapshot/latest/fix_assert/) more about this feature.\n\n\n- **Intuitive Semantics:** `snapshot(x)` mirrors `x` for easy understanding.\n- **Versatile Comparison Support:** Equipped with\n    [`x == snapshot(...)`](https://15r10nk.github.io/inline-snapshot/latest/eq_snapshot/),\n    [`x \u003c= snapshot(...)`](https://15r10nk.github.io/inline-snapshot/latest/cmp_snapshot/),\n    [`x in snapshot(...)`](https://15r10nk.github.io/inline-snapshot/latest/in_snapshot/), and\n    [`snapshot(...)[key]`](https://15r10nk.github.io/inline-snapshot/latest/getitem_snapshot/).\n- **Enhanced Control Flags:** Utilize various [flags](https://15r10nk.github.io/inline-snapshot/latest/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- **Customizable:** code generation can be customized with [@customize_repr](https://15r10nk.github.io/inline-snapshot/latest/customize_repr)\n- **Nested Snapshot Support:** snapshots can contain [other snapshots](https://15r10nk.github.io/inline-snapshot/latest/eq_snapshot/#inner-snapshots)\n- **Fuzzy Matching:** Incorporate [dirty-equals](https://15r10nk.github.io/inline-snapshot/latest/eq_snapshot/#dirty-equals) for flexible comparisons within snapshots.\n- **Dynamic Snapshot Content:** snapshots can contain [non-constant values](https://15r10nk.github.io/inline-snapshot/latest/eq_snapshot/#is)\n- **Comprehensive Documentation:** Access detailed [documentation](https://15r10nk.github.io/inline-snapshot/latest) for complete guidance.\n\n\n## Usage\n\nYou can use `snapshot()` instead of the value which you want to compare with.\n\n\u003c!-- inline-snapshot: first_block outcome-passed=1 outcome-errors=1 --\u003e\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=review\n```\n\n\u003c!-- inline-snapshot: create outcome-passed=1 outcome-errors=1 --\u003e\n``` python hl_lines=\"5\"\nfrom inline_snapshot import snapshot\n\n\ndef test_something():\n    assert 1548 * 18489 == snapshot(28620972)\n```\n\nThe following examples show how you can use inline-snapshot in your tests. Take a look at the\n[documentation](https://15r10nk.github.io/inline-snapshot/latest) if you want to know more.\n\n\u003c!-- inline-snapshot: create fix trim first_block outcome-passed=1 outcome-errors=1 --\u003e\n``` python\nfrom inline_snapshot import external, outsource, snapshot\n\n\ndef test_something():\n    for number in range(5):\n        # testing for numeric limits\n        assert number \u003c= snapshot(4)\n        assert number \u003e= 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 \u0026 (number - 1) == 0) and number != 0\n        )\n\n    assert outsource(\"large string\\n\" * 1000) == snapshot(\n        external(\"hash:8bf10bdf2c30*.txt\")\n    )\n\n    assert \"generates\\nmultiline\\nstrings\" == snapshot(\n        \"\"\"\\\ngenerates\nmultiline\nstrings\\\n\"\"\"\n    )\n```\n\n\n`snapshot()` can also be used as parameter for functions:\n\n\u003c!-- inline-snapshot: create fix trim first_block outcome-passed=1 --\u003e\n``` python\nimport subprocess as sp\nimport sys\nfrom inline_snapshot import snapshot\n\n\ndef run_python(cmd, stdout=None, stderr=None):\n    result = sp.run([sys.executable, \"-c\", cmd], capture_output=True)\n    if stdout is not None:\n        assert result.stdout.decode() == stdout\n    if stderr is not None:\n        assert result.stderr.decode() == stderr\n\n\ndef test_cmd():\n    run_python(\n        \"print('hello world')\",\n        stdout=snapshot(\n            \"\"\"\\\nhello world\n\"\"\"\n        ),\n        stderr=snapshot(\"\"),\n    )\n\n    run_python(\n        \"1/0\",\n        stdout=snapshot(\"\"),\n        stderr=snapshot(\n            \"\"\"\\\nTraceback (most recent call last):\n  File \"\u003cstring\u003e\", line 1, in \u003cmodule\u003e\nZeroDivisionError: division by zero\n\"\"\"\n        ),\n    )\n```\n\n\u003c!-- -8\u003c- [start:Feedback] --\u003e\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\u003c!--[[[cog\nimport requests,cog\n\nurl = \"https://raw.githubusercontent.com/15r10nk/sponsors/refs/heads/main/sponsors_readme.md\"\nresponse = requests.get(url)\nresponse.raise_for_status()  # Raise an exception for bad status codes\ncog.out(response.text)\n]]]--\u003e\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### Silver sponsor 🥈\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://pydantic.dev/logfire\"\u003e\n    \u003cimg src=\"https://pydantic.dev/assets/for-external/pydantic_logfire_logo_endorsed_lithium_rgb.svg\" alt=\"logfire\" width=\"300\"/\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003c!--[[[end]]]--\u003e\n\nI have also started to offer [insider](https://15r10nk.github.io/inline-snapshot/latest/insiders/) features for inline-snapshot. I will only release features as insider features if they will not cause problems for you when used in an open source project.\nI hope sponsoring will allow me to spend more time working on open source projects.\nThank you for using inline-snapshot, the future will be 🚀.\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\u003c!-- -8\u003c- [end:Feedback] --\u003e\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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F15r10nk%2Finline-snapshot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F15r10nk%2Finline-snapshot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F15r10nk%2Finline-snapshot/lists"}