Skip to main content

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

Project description

run-snapshot-tests

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

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 loguru import logger
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 loguru import logger
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.1.2.tar.gz (44.1 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.1.2-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for run_snapshot_tests-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d5dd1e0e6132348f5671080217ee505aec7fb63623124efd89a1ac2793eafcd8
MD5 93a29278de98419cb9d5668d57773faf
BLAKE2b-256 f321572d390000409ef5f4aad11805e8c2bb3f9252dd5bf9bef4b759c7f58a10

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for run_snapshot_tests-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2343f6340934f6929e7e93350fb402b62d27cf068ee1a80885ffae0d936ebec9
MD5 6fc89255d49bf298e18c9eebecad0e34
BLAKE2b-256 2b22f0ab60c5e704e19e8728ad6036483dcc92eb9f234ec4920fe0b3272cb607

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