inline-snapshot

0.32.6 · active · verified Sat Apr 11

inline-snapshot is a Python library for golden master/snapshot/approval testing, designed to store expected values directly within your source code. It automates the process of recording, storing, and updating these values, integrating seamlessly with pytest for an enhanced developer experience. The library is currently at version 0.32.6 and receives regular updates, often with minor patch releases to address bugs and improve compatibility.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates the core functionality of inline-snapshot. Initially, `snapshot()` is called without an argument. Running `pytest --inline-snapshot=create` will execute the test, capture the actual result, and automatically insert it as an argument to `snapshot()` in your source code. Subsequent runs will compare against this recorded value.

from inline_snapshot import snapshot
import pytest

def test_calculation():
    result = 1548 * 18489
    assert result == snapshot()

# To run this test and generate the snapshot value:
# pytest --inline-snapshot=create your_test_file.py
# The 'snapshot()' in the code will be updated to 'snapshot(28620972)'.

view raw JSON →