pytest-snapshot is a plugin for snapshot testing with pytest. It enables developers to compare current test outputs (e.g., data structures, HTML, JSON) against a pre-recorded 'snapshot', failing tests if a mismatch occurs. The current version is 0.9.0, and it maintains an active release schedule with regular minor and patch updates.
pip install pytest-snapshotVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use the `snapshot` fixture within a pytest function to test a Python dictionary. The first execution with `--snapshot-update` creates the baseline snapshot; subsequent runs verify that the data structure remains consistent.
Always use `pytest --snapshot-update` when you intend to create or modify snapshot files.
Ensure your testing environment uses Python 3.5 or a more recent version.
It is recommended to regenerate all existing snapshots after upgrading to version 0.5.0 or later to ensure consistent UTF-8 encoding.
Modify the data to remove unsupported characters or types before passing it to `snapshot.assert_match`, or handle such cases explicitly in your test logic.
Upgrade to version 0.8.1 or newer to ensure robust exception handling. If unable to upgrade, avoid using `--assert=plain` in conjunction with `pytest-snapshot` without `--snapshot-update`.
No dependency data recorded yet.