--- id: pytest-snapshot version: "0.9.0" license: MIT license_treatment: permissive maintenance: dormant --- # pytest-snapshot — A plugin for snapshot testing with pytest. License: permissive · Maintenance: dormant · Downloads: 2.6M/mo ## What it is and what it does pytest-snapshot is a pytest plugin that implements snapshot testing—a pattern where test assertions compare actual output against saved reference files (snapshots) rather than hardcoded expected values. When a function's output changes, you run pytest with --snapshot-update to regenerate snapshots, review the changes, and commit them to version control. This reduces boilerplate in tests and makes it easy to spot when behavior changes unexpectedly. The plugin works with strings and bytes directly, and supports both single-file snapshots (via assert_match) and directory-based snapshot collections (via assert_match_dir). It gives you full control over snapshot file paths and serialization—you decide how to format output (JSON, YAML, plain text) before passing it to the snapshot method. The design is inspired by Jest's snapshot testing and emphasizes human-readable snapshots that are easy to review in code diffs and pull requests. Use it for: - Testing formatted output (JSON, YAML, HTML) where manual assertion maintenance is tedious. - Regression testing large or complex data structures by comparing against golden files. - Parametrized tests over many input cases, where each case's expected output is stored in a separate snapshot file. - Verifying that refactoring or API changes produce expected output changes, with easy bulk review via --snapshot-update. - Organizing test fixtures as readable snapshot files in version control rather than embedded test constants. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. A pytest plugin that enables snapshot testing—comparing test outputs against saved reference files to detect unexpected changes without manual assertion updates. Yes, if you use pytest and want to reduce assertion boilerplate in tests with large or frequently-changing outputs. The low install friction and permissive license make adoption straightforward. However, maintenance is dormant; verify compatibility with your pytest and Python versions before relying on it for new projects, and monitor the repository for any compatibility issues. ## Install pip install pytest-snapshot uv add pytest-snapshot poetry add pytest-snapshot ## Installing pytest-snapshot Before you install: Low friction; a single runtime dependency on pytest. Maintenance is dormant—last release was 2022-04-23—but the repository remains active and the package is stable at Beta status. License in practice: MIT license is permissive; you may use, modify, and distribute this package freely in commercial and private projects without restriction. Quickstart: pip install pytest-snapshot # In your test file: def test_output(snapshot): result = some_function() snapshot.assert_match(result, 'expected_output.txt') # Run: pytest --snapshot-update Requires pytest 3.0+; Python 3.5+. Verify before relying: - Whether the dormant maintenance status affects compatibility with recent pytest or Python versions. - Performance characteristics when snapshot testing large collections or deeply nested structures. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: dormant - Downloads: 2.6M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags snapshot testing pytest, regression testing with snapshots, pytest output comparison, golden file testing, snapshot assertion testing, testing, regression-testing [View on SkillFed](https://skillfed.io/packages/pytest-snapshot) · [View on PyPI](https://pypi.org/project/pytest-snapshot/)