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

Snapshot-Driven Sensor Report

Produce deterministic summaries for environmental sensor readings that are intended to be verified via snapshot-based tests. Outputs should stay stable across runs so intentional format changes can be refreshed with the snapshot plugin's update option.

Capabilities

Base summary snapshot

  • Building a report for sample readings with default rounding returns summary fields (count, min, max, average, sorted locations) and a sorted breakdown of readings keyed by sensor/location that matches the stored snapshot @test

Adjustable rounding snapshot

  • Building a report with decimal precision set to 1 produces rounded numeric fields and breakdown values that match a distinct stored snapshot @test

Optional breakdown snapshot

  • Building a report while disabling the breakdown returns only the summary section, preserving deterministic ordering and snapshot match for the truncated structure @test

Implementation

@generates

API

from typing import Iterable, Mapping, Any

def build_report(readings: Iterable[Mapping[str, Any]], *, decimals: int = 2, include_breakdown: bool = True) -> dict[str, Any]:
    """
    Create a deterministic report for environmental sensor readings.
    - readings contain keys: "sensor", "location", and "value" (numeric).
    - Returns a mapping with:
      - "summary": count, min, max, average (rounded to decimals), and sorted unique locations.
      - "breakdown": when requested, a list of normalized reading entries sorted by location then sensor with values rounded and fields (sensor, location, value, status="ok").
    The output must be stable across runs so stored snapshots remain valid or update cleanly.
    """

Dependencies { .dependencies }

syrupy { .dependency }

Pytest snapshot plugin used to assert structured reports and refresh stored expectations when outputs legitimately change.

Install with Tessl CLI

npx tessl i tessl/pypi-syrupy

tile.json