CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-syrupy

Pytest snapshot testing utility that enables developers to write tests asserting immutability of computed results.

Overall
score

80%

Overview
Eval results
Files

task.mdevals/scenario-5/

Snapshot Discovery Runner

Implement a small helper that runs snapshot-based tests with customized discovery settings for where snapshots live and which files are ignored. The helper must lean on the snapshot plugin's CLI flags for directory naming and ignored extensions rather than reimplementing snapshot discovery.

Capabilities

Custom snapshot directory

  • Running with defaults stores snapshots in a directory named __custom_snaps__ adjacent to the test path while preserving passing assertions. @test

Ignored extensions skipped

  • When provided a list like [".tmp", ".cache"], the runner ensures those extensions are excluded from snapshot discovery and cleanup so temporary files remain untouched after an update pass. @test

Override-friendly configuration

  • Overrides for directory name and ignored extensions are propagated to the test run so snapshots are written to the requested directory and the provided ignore list is respected in the same execution. @test

Implementation

@generates

API

from collections.abc import Sequence
from subprocess import CompletedProcess
from typing import List, Optional

def build_snapshot_args(snapshot_dirname: str = "__custom_snaps__", ignored_extensions: Optional[Sequence[str]] = None) -> List[str]:
    """
    Construct pytest command-line arguments that enforce the chosen snapshot directory name
    and ignored file extensions for snapshot discovery via the plugin's discovery flags.
    """


def run_with_snapshot_discovery(
    test_paths: Sequence[str],
    snapshot_dirname: str = "__custom_snaps__",
    ignored_extensions: Optional[Sequence[str]] = None,
    *,
    update_snapshots: bool = False,
    extra_args: Optional[Sequence[str]] = None,
) -> CompletedProcess[str]:
    """
    Execute pytest for the given test paths using the snapshot discovery configuration
    produced by build_snapshot_args, optionally enabling snapshot updates.
    """

Dependencies { .dependencies }

syrupy { .dependency }

Pytest snapshot testing plugin supplying snapshot discovery controls for directory naming and ignored file extensions. @satisfied-by

Install with Tessl CLI

npx tessl i tessl/pypi-syrupy

tile.json