Skip to content

About

Easily spot regressions in your tests.

Topics

Resources

Stars

6 stars

Watchers

1 watching

Forks

Repository files navigation

pytest-results

PyPI - Version PyPI - Downloads GitHub Stars CI Ruff

Easily spot regressions in your tests.

A Pytest plugin for snapshot testing: a test returns a value, the plugin stores it in a snapshot file, and compares the next runs with it.

Installation

⚠️ Requires Python 3.12 or higher

pip install pytest-results

Quick start

Return the value to check from your test:

def test_function():
    return {"hello": "world"}

The first run fails, since there is no snapshot to compare with yet. Accept the new results to store them as snapshots:

pytest --accept-diff

The snapshots are stored as JSON files in the __pytest_results__ folder, at the root of your project. Commit this folder: from now on, the test fails whenever its result changes.

When a test fails, open the differences in your IDE with the --ide option:

pytest --ide vscode

The supported IDEs are cursor, pycharm and vscode.

If the changes are expected, update the snapshots with pytest --accept-diff.

Documentation

About

Easily spot regressions in your tests.

Topics

Resources

Stars

6 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages