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-1/

Snapshot Regeneration Guard

A small helper that produces deterministic run summaries and relies on snapshot assertions to flag corrupted files and strict type drift before regeneration.

Capabilities

Stable summary snapshot

  • Given run_id="build-42", metrics={"duration_ms": 1820, "files_written": 3}, and artifacts ["results.json", "log.txt"], the returned summary contains these values, includes an integrity marker {"stable": True}, sorts artifacts alphabetically, and matches the stored snapshot exactly. @test

Strict type drift detection

  • When metrics provides duration_ms as a string instead of an integer, the snapshot assertion fails with a strict type mismatch pointing at the duration path rather than coercing the value. @test

Tainted snapshot rejection

  • After intentionally editing the stored snapshot for the baseline summary (for example, changing the artifacts list), the assertion raises a corruption/regeneration error instead of accepting or diffing the altered snapshot. @test

Regeneration heals corruption

  • With snapshot regeneration enabled, re-running the baseline summary assertion rewrites the altered snapshot and passes while keeping the canonical data shape. @test

Implementation

@generates

API

from typing import Dict, List, Any

def build_run_summary(run_id: str, metrics: Dict[str, Any], artifacts: List[str]) -> Dict[str, Any]:
    """
    Returns a deterministic summary shaped as:
    {
        "run_id": run_id,
        "metrics": metrics,  # expects numeric millisecond durations
        "artifacts": sorted(artifacts),
        "integrity": {"stable": True}
    }
    """

Dependencies { .dependencies }

syrupy { .dependency }

Python snapshot testing library used for deterministic snapshot assertions and regeneration workflows.

Install with Tessl CLI

npx tessl i tessl/pypi-syrupy

tile.json