Skip to main content

golden master/snapshot/approval testing library which puts the values right into your source code

Project description

inline-snapshot

Docs pypi version PyPI - Downloads GitHub Sponsors

create and update inline snapshots in your code.

Installation

You can install "inline-snapshot" via pip:

pip install inline-snapshot

Usage

You can use snapshot() instead of the value which you want to compare with.

from inline_snapshot import snapshot


def test_something():
    assert 1548 * 18489 == snapshot()

You can now run the tests and record the correct values.

$ pytest --inline-snapshot=create
from inline_snapshot import snapshot


def test_something():
    assert 1548 * 18489 == snapshot(28620972)

Features

  • manage snapshots with pytest --inline-snapshot=(create,update,fix,trim).
  • uses repr() to convert the value to python code.
  • values are stored in the source code and not in separate files.
  • snapshot() supports the following operations:
    • x == snapshot()
    • x <= snapshot()
    • x >= snapshot()
    • x in snapshot()
    • snapshot()[key]
  • code is formatted with black if the file was already formatted with black.

More information can be found in the documentation.

Contributing

Contributions are very welcome. Tests can be run with nox. Please use pre-commit for your commits.

License

Distributed under the terms of the MIT license, "inline-snapshot" is free and open source software.

Issues

If you encounter any problems, please file an issue along with a detailed description.

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

inline_snapshot-0.2.1.tar.gz (10.3 kB view hashes)

Uploaded Source

Built Distribution

inline_snapshot-0.2.1-py3-none-any.whl (11.1 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