Skip to main content

A flexible and user-friendly snapshot testing plugin for pytest

Project description

pytest-insta

A flexible and user-friendly snapshot testing plugin for pytest.

assert snapshot() == "awesome!"

Introduction

Snapshot testing makes it easy to monitor and approve changes by comparing the result of an operation against a previous reference value.

This project borrows from a lot of other implementations but reinterprets what it means to work with snapshots in an expressive language like Python. It also tries to feel as native to pytest as possible with its integrated reviewing tool.

Features

  • Expressive and familiar assertion syntax
  • Named and unnamed snapshots
  • Handles text, binary, hexdump, json and pickle snapshots out-of-the-box
  • The plugin can be extended with custom snapshot formats
  • Integrated reviewing tool with live repl for inspecting the new value and the old value

Credits

  • insta (rust)

    Armin's work was the initial inspiration for this project and shaped the reviewing workflow. The name was cool too. 😎

  • jest (javascript)

    Jest enabled the mass-adoption of snapshot testing throughout the JavaScript ecosystem and now basically stands as the reference when it comes to what snapshot testing is supposed to look like.

Installation

The package can be installed with pip.

$ pip install pytest-insta

Contributing

Contributions are welcome. This project uses poetry.

$ poetry install

You can run the tests with poetry run pytest.

$ poetry run pytest

The project must type-check with mypy and pylint shouldn't report any error.

$ poetry run mypy
$ poetry run pylint pytest_insta tests

The code follows the black code style. Import statements are sorted with isort.

$ poetry run isort pytest_insta tests
$ poetry run black pytest_insta tests
$ poetry run black --check pytest_insta tests

License - MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-insta-0.0.1.tar.gz (9.4 kB view hashes)

Uploaded Source

Built Distribution

pytest_insta-0.0.1-py3-none-any.whl (10.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page