Skip to main content

Runner for Python [inline-snapshot](https://github.com/15r10nk/inline-snapshot/) tests with a better interface and cleaner terminal output.

Project description

run-snapshot-tests

Runner for Python inline-snapshot tests with a better interface and cleaner terminal output.

Note: requires inline-snapshot==0.8.0. No plans to update to newer versions for now, this works just fine with a couple of monkey-patched fixes.

Interface

def run_snapshot_tests(
    path: Union[str, Path, None] = None, # tests path. Defaults to current file if not set
    mode: Literal[
        "assert", 
        "create_missing", 
        "fix_broken", 
        "update_all"
    ] = "create_missing",
) -> None:

Example

from inline_snapshot import outsource, snapshot
from run_snapshot_tests import run_snapshot_tests

def test():
    assert "value" == snapshot()
    assert 5 <= snapshot()
    assert 5 in snapshot()
    a = snapshot()
    assert a["key"] == "value"

    assert (
        outsource(
            "Long data" * 1000,
        )
        == snapshot()
    )


if __name__ == "__main__":
    run_snapshot_tests()

from inline_snapshot import outsource, snapshot
from run_snapshot_tests import run_snapshot_tests

from inline_snapshot import external


def test():
    assert "value" == snapshot('value')
    assert 5 <= snapshot(5)
    assert 5 in snapshot([5])
    a = snapshot({'key': 'value'})
    assert a["key"] == "value"

    assert (
        outsource(
            "Long data" * 1000,
        )
        == snapshot(external("hash:dc9b148c966a*.txt"))
    )


if __name__ == "__main__":
    run_snapshot_tests()

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

run_snapshot_tests-0.3.0.tar.gz (51.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

run_snapshot_tests-0.3.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file run_snapshot_tests-0.3.0.tar.gz.

File metadata

  • Download URL: run_snapshot_tests-0.3.0.tar.gz
  • Upload date:
  • Size: 51.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.2

File hashes

Hashes for run_snapshot_tests-0.3.0.tar.gz
Algorithm Hash digest
SHA256 7a14bdeaf71cd56d429a25cd9a03c8739015a89af8204628625bf8f947b5d261
MD5 970b30a153bf7b12a42886a13e353791
BLAKE2b-256 0b79352de3a6638a331f0d6435c766f4b41d3ab6c8e008d01e6e79960f91afa6

See more details on using hashes here.

File details

Details for the file run_snapshot_tests-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for run_snapshot_tests-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3f4c01cff83f15f36abc589b5d73fd18480c21e6c6c5276d55d21578f52edcfc
MD5 5eb2cb019bfc41d3617237c0f44ab29f
BLAKE2b-256 3d0e2179939a5e89c0035bd541f4920dc2771b840d3fbfe948e9f3718a5333bd

See more details on using hashes here.

Supported by

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