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