Pytest snapshot testing utility that enables developers to write tests asserting immutability of computed results.
Overall
score
80%
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.
__custom_snaps__ adjacent to the test path while preserving passing assertions. @test@generates
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.
"""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-syrupyevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10