inline-snapshot
golden master/snapshot/approval testing library which puts the values right into your source code
What it is and what it does
inline-snapshot is a pytest plugin that embeds snapshot values directly in your test source code, turning snapshot testing into a code-first workflow. Instead of storing expected values in separate files, you write `snapshot()` placeholders in assertions, then run pytest with `--inline-snapshot=review` to see what values the test produces and approve them inline. The plugin rewrites your test file with the actual values, keeping your assertions and test logic in one place.
It supports multiple comparison modes (equality, ordering, membership, indexing), can store large snapshots externally, integrates with Black formatting, and works with normal assertions like `assert 1 + 1 == 3` as well as snapshot-specific syntax. Runtime dependencies are minimal: asttokens, executing, pytest, rich, tomli, and typing-extensions. The package is actively maintained, supports Python 3.9 through 3.14, and has no known security vulnerabilities.
Use it for:
- Verify complex output (JSON, HTML, error messages) by embedding the expected result in your test and auto-updating it when the output legitimately changes.
- Test function arguments and return values by using snapshot_arg() to capture and compare function parameters across test runs.
- Maintain approval tests for command-line tools or subprocess output where you want to review and lock in expected behavior.
- Compare structured data (nested dicts, lists) with fuzzy matching support via dirty-equals for flexible assertions on dynamic parts.
- Store large or multiline snapshot data externally while keeping test logic readable and inline.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
inline-snapshot is a pytest plugin that lets you write snapshot tests by embedding expected values directly in your test code, then automatically updates those values when you review and approve changes.
Yes. inline-snapshot is actively maintained, has low install friction, zero known vulnerabilities, and solves a real problem for teams doing approval or golden-master testing. The inline-code-first approach is a genuine alternative to file-based snapshot tools. Install it if you want snapshot testing without managing separate snapshot files, or if you prefer reviewing and approving test changes as part of code review.
Install
inline-snapshot on PyPI
pip
pip install inline-snapshotuv
uv add inline-snapshotpoetry
poetry add inline-snapshotInstalling inline-snapshot
Before you install
Low friction install with a pure-Python wheel. Active maintenance: released 3 days ago with 749 repository stars. Depends on six runtime packages (asttokens, executing, pytest, rich, tomli, typing-extensions), all common testing and utility libraries.
License in practice
MIT license (permissive). Free to use, modify, and distribute in both open-source and commercial projects with minimal restrictions.
Quickstart
pip install inline-snapshot
from inline_snapshot import snapshot
def test_something():
assert 1548 * 18489 == snapshot(28620972)
Requires pytest to be installed and tests to be run via pytest; review mode works best on CPython 3.11+ (older versions require --inline-snapshot=review flag).
Verify before relying
- Whether the package works reliably with PyPy in practice despite classifier support.
- Performance impact when working with very large snapshot datasets or many snapshots per test file.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 6 — asttokens, executing, pytest, rich, tomli, typing-extensions |
| Maintenance | actively maintained — 3 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,126,963/month — #3,271 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: inline_snapshot-0.35.4-py3-none-any.whl
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
pytest-instaA pytest plugin that enables snapshot testing…
unclear · top 15,000 on PyPI
pytest-snapshotA pytest plugin that enables snapshot…
permissive · top 5,000 on PyPI
pytest-textual-snapshotA pytest plugin that captures SVG screenshots…
permissive · top 15,000 on PyPI
snapshottestSnapshot testing library that captures API…
permissive · top 15,000 on PyPI
syrupySyrupy is a pytest plugin that enables snapshot…
permissive · top 5,000 on PyPI
pytest-playwright-visualA pytest plugin that captures and compares…
permissive · top 15,000 on PyPI
expecttestexpecttest implements inline golden tests where…
permissive · top 5,000 on PyPI
pytest-regressionsProvides pytest fixtures for writing regression…
permissive · top 5,000 on PyPI
approvaltestsApprovalTests provides a snapshot-based…
permissive · top 15,000 on PyPI
assertpyProvides a fluent assertion API for writing…
permissive · top 5,000 on PyPI