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 details)

Uploaded Source

Built Distribution

inline_snapshot-0.2.1-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file inline_snapshot-0.2.1.tar.gz.

File metadata

  • Download URL: inline_snapshot-0.2.1.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.0 CPython/3.11.0 Linux/5.10.0-23-amd64

File hashes

Hashes for inline_snapshot-0.2.1.tar.gz
Algorithm Hash digest
SHA256 768cc88d29097db025ee801c1ecd9f3b848ad0002604dcdbb86ce9342832271e
MD5 4965728769d41f51eee39ceb6f746def
BLAKE2b-256 a0c060c1fa2faf2db6db4cb3af8fc14111c68fd584bae6df28f7215fc4869fae

See more details on using hashes here.

File details

Details for the file inline_snapshot-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: inline_snapshot-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.0 CPython/3.11.0 Linux/5.10.0-23-amd64

File hashes

Hashes for inline_snapshot-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 160d566c9e4201891b27751a06f761c7ce0b0d8663fc95065f10795d51cb5c59
MD5 c3d6aed15a70dc6b39f4d157fef83365
BLAKE2b-256 52452ef780d2ef1a4fcbdd73578f657931dcf4889d64b9a2db813abf3d42bd71

See more details on using hashes here.

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