DEV.co
Open-Source Testing · 15r10nk

inline-snapshot

inline-snapshot is a pytest plugin for Python that automates snapshot testing by generating and updating expected values directly in test code. It supports multiple comparison operators, external file storage, and integrates seamlessly with pytest workflows.

Source: GitHub — github.com/15r10nk/inline-snapshot
741
GitHub stars
26
Forks
Python
Primary language
MIT
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repository15r10nk/inline-snapshot
Owner15r10nk
Primary languagePython
LicenseMIT — OSI-approved
Stars741
Forks26
Open issues30
Latest release0.34.2 (2026-06-19)
Last updated2026-07-07
Sourcehttps://github.com/15r10nk/inline-snapshot

What inline-snapshot is

A pytest plugin providing snapshot testing with inline code generation, supporting equality, comparison, membership, and item-access assertions. Features include Black formatting preservation, fuzzy matching via dirty-equals, nested snapshots, and customizable code generation via plugin hooks.

Quickstart

Get the inline-snapshot source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/15r10nk/inline-snapshot.gitcd inline-snapshot# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

Regression testing with frequent output changes

Ideal for tests where expected values change often but the logic is correct. Developers can review and approve snapshot changes inline without manual assertion updates.

API and data structure validation

Capture and validate complex JSON responses, data structures, or computed outputs. External file storage keeps test files readable while storing large snapshots separately.

Golden-master approval testing

Establish baseline outputs for complex systems (rendering, formatting, reports). Review mode provides a user-friendly interface for approving or rejecting snapshot updates.

Implementation considerations

  • Review and commit snapshot changes explicitly; automate carefully in CI to prevent unintended test passes.
  • Configure Black formatting or custom format-command to maintain code style consistency across snapshots.
  • Use fuzzy matching (dirty-equals) for semi-deterministic values (UUIDs, timestamps) to reduce snapshot churn.
  • Leverage external() for large snapshots to keep test files readable and diffs manageable.
  • Plan snapshot storage strategy early (inline vs. external files) based on team workflow and review practices.

When to avoid it — and what to weigh

  • Non-deterministic test outputs — If test values vary between runs (timestamps, random IDs, unstable order), snapshots will fail. Requires fuzzy matching with dirty-equals or dynamic snapshot values (both supported but add complexity).
  • Security-sensitive expected values — Storing secrets, keys, or sensitive data in inline snapshots or external files poses risk. Not suitable for tests containing production credentials or PII.
  • Binary or very large artifacts — While external storage is supported, inline-snapshot is optimized for text/code comparison. Large binary files or streaming data may be better served by dedicated golden-file tools.
  • Minimal test infrastructure — Requires pytest and Python 3.8+. If your test suite avoids pytest or uses older Python, integration effort is significant.

License & commercial use

Licensed under MIT (permissive, OSI-compliant). Permits commercial use, modification, and distribution with minimal restrictions (retain license and copyright notice).

MIT license permits commercial use, derivative works, and bundling with proprietary software. No restrictions on commercial testing scenarios. No warranty provided; use at own risk.

DEV.co evaluation signals

Editorial assessment — not user reviews. Directional, with an explicit confidence level.

SignalAssessment
MaintenanceActive
DocumentationStrong
License clarityClear
Deployment complexityLow
DEV.co fitStrong
Assessment confidenceHigh
Security considerations

No inherent security vulnerabilities disclosed. Consider: (1) snapshots stored in version control are visible to all repo access; (2) external snapshot files require proper file permissions; (3) ensure test data does not contain secrets before generating snapshots; (4) code generation via customization hooks should validate inputs to prevent injection.

Alternatives to consider

pytest-snapshot / snapshottest

Older snapshot libraries using external files by default. Less inline integration and fewer comparison operators, but may suit projects wanting file-based-only snapshots.

Golden Master (manual)

Manual approval-testing pattern with plain assertions. Avoid repeated snapshot regeneration logic but no automation; higher maintenance burden.

testfixtures / approvals libraries (Java/C#-style)

Language-specific equivalents (ApprovalTests.Python). More mature in some ecosystems but inline-snapshot is more Pythonic and pytest-native.

Software development agency

Build on inline-snapshot with DEV.co software developers

inline-snapshot reduces friction in approval testing. Start with pip install and try it on a single test file to see snapshot review workflow in action.

Talk to DEV.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

Related on DEV.co

Explore the category and the services that help you build with it.

inline-snapshot FAQ

Can I use inline-snapshot in CI/CD without accidental snapshot commits?
Yes. Use pytest flags (--inline-snapshot=review or older --inline-snapshot) to control update behavior. In CI, omit flags to enforce strict snapshot matching. Review snapshots in PR before merge.
How do I handle non-deterministic test output (UUIDs, timestamps)?
Use fuzzy matching with dirty-equals library (supported natively) or snapshot(...)[key] with dynamic values via snapshot.Is(). Alternatively, mock time/UUIDs in tests.
Does inline-snapshot work with non-pytest test runners?
No, it is pytest-specific. Requires pytest as a plugin. Other test runners are not supported.
What Python versions are supported?
Python 3.8+. CPython 3.11+ enables enhanced review mode; older versions require --inline-snapshot=review CLI flag.

Software development & web development with DEV.co

From first prototype to production, DEV.co delivers software development services around tools like inline-snapshot. Our software development agency staffs experienced software developers and web developers for custom software development, web development, integrations, and ongoing support across open-source testing and beyond.

Ready to streamline your snapshot testing?

inline-snapshot reduces friction in approval testing. Start with pip install and try it on a single test file to see snapshot review workflow in action.