skillfed

syrupy

Pytest Snapshot Test Utility

syrupy v5.5.3 13.4M downloads/30d#1,285 on PyPI872
Permissive license MIT Active released

What it is and what it does

Syrupy is a pytest plugin that implements snapshot testing—a pattern where test assertions compare computed output against stored reference snapshots to detect regressions. Instead of writing brittle assertions on exact values, you write `assert actual == snapshot`, and syrupy manages the stored snapshots for you. On first run, it fails and prompts you to generate snapshots; on subsequent runs, it compares against those stored files. If output changes, the test fails, alerting you to the difference. You can update snapshots with `pytest --snapshot-update` when changes are intentional.

The plugin is designed around three principles: extensibility (you can add custom serializers for unsupported types), idiomatic pytest style (snapshots work as natural assertions, not special methods), and soundness (tests fail if a snapshot is missing, not just on differences). It supports filtering object attributes via include/exclude functions, customizing serialization through `__repr__` overrides, and integrating with unittest TestCase subclasses through fixtures. Snapshots are stored in a `__snapshots__` directory alongside your tests and should be committed to version control.

Use it for:

  • Regression testing of complex data structures, API responses, or rendered output where exact values matter but are hard to predict.
  • Validating that refactoring or optimization changes don't alter computed results unexpectedly.
  • Testing serialization and deserialization of custom objects by comparing their snapshot representation.
  • Detecting unintended changes to generated code, configuration, or formatted output in CI/CD pipelines.
  • Documenting expected behavior by storing snapshots as living examples of what your code produces.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Syrupy is a pytest plugin that enables snapshot testing by letting you assert that computed results remain unchanged across test runs, using simple equality comparisons like `assert actual == snapshot`.

Yes. Syrupy is actively maintained, has no security vulnerabilities, installs with minimal friction, and solves a real testing problem—regression detection on complex outputs. It's well-suited for projects that need to catch subtle changes in computed results. Install it if you're writing tests for data transformations, API responses, or any output where immutability matters but exact assertions are unwieldy.

Install

syrupy on PyPI

pip

pip install syrupy

uv

uv add syrupy

poetry

poetry add syrupy

Installing syrupy

Before you install

Installs with low friction as a pure Python wheel with only pytest as a runtime dependency. Actively maintained with a recent release; compatible with current Python versions (3.10+) and recent pytest versions (8+).

License in practice

MIT license permits free use, modification, and distribution with minimal restrictions, making it suitable for both open-source and proprietary projects.

Quickstart

pip install syrupy

# In test_example.py:
def test_foo(snapshot):
    actual = "Some computed value!"
    assert actual == snapshot

# Run: pytest --snapshot-update

Requires Python 3.10 or later and pytest 8 or later; snapshot fixture does not work directly in unittest.TestCase subclasses without a workaround.

Verify before relying

  • Performance characteristics when handling very large snapshots or deeply nested object graphs.
  • Exact extent of custom serializer extensibility beyond built-in types and __repr__ overrides.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 1 — pytest
Maintenance actively maintained — 34 days since the last release
Last repo commit
First released
Downloads 13,351,369/month — #1,285 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: syrupy-5.5.3-py3-none-any.whl

Development Status :: 5 - Production/StableFramework :: PytestIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Software Development :: LibrariesTopic :: Software Development :: TestingTopic :: Utilities

Tags

pytest snapshot testingsnapshot test pluginassert immutability testingregression test snapshotspytest fixture snapshotgolden file testingoutput comparison testing
testing-utilitiesregression-testing

More Libraries packages