test/chore: compare snapshots by pixels; small resource and robustness fixes#32
Merged
Merged
Conversation
…s fixes - C1: compare visual snapshots by decoded pixels instead of raw PNG bytes. PixelPNGImageSnapshotExtension decodes both sides and diffs all channels (alpha_only=False), so a Pillow/zlib re-encode of identical pixels no longer breaks every snapshot. The 12 text-bearing baselines are refreshed to the supported Pillow 12 rasterization (they were generated on an older Pillow and differed by ~1px); shape/QR baselines were already pixel-identical and are unchanged. Full suite now 409 passed / 0 failed (was 29 failed). - A12: media_loader now calls Image.load() for file and HTTP sources so the file handle is released and decoding happens up front, not mid-composite; warmup continues past a failing font size instead of breaking (and logs it); plot normalizes naive last_changed timestamps to UTC instead of raising TypeError on aware-vs-naive subtraction; the DataProvider protocol documents the timezone expectation. - B9: load_image warns once (not every frame) when it has to create a throwaway aiohttp session, nudging callers to pass a shared one. Adds unit tests for the pixel snapshot matcher, warmup continue-on-failure, the file-handle release, and the naive-timestamp plot path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UVpLN4Rzdv7y3ud7QzutVJ
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the brittle visual-snapshot comparison (which fails on
mainunder Pillow 12) plus a handful of small resource/robustness notes.Findings addressed
tests/visual/*test asserted on encoded PNG bytes, so a Pillow/zlib re-encode of pixel-identical output broke the snapshot — 29 of them fail onmainunder Pillow 12. AddedPixelPNGImageSnapshotExtension, which decodes both sides and diffs pixels across all channels (getbbox(alpha_only=False)— the defaultalpha_only=Truewould ignore RGB changes on fully-opaque e-paper renders). The 12 text-bearing baselines are refreshed to the supported Pillow 12 rasterization (they were generated on an older Pillow and differed by ~1px, flipping some black/white text pixels); the 17 shape/QR baselines were already pixel-identical and are byte-unchanged. The suite now runs 409 passed / 0 failed (was 29 failed).media_loadercallsImage.load()for file and HTTP sources, so the file handle is released (noResourceWarningunder-W error) and decoding happens up front instead of lazily mid-composite.warmupnowcontinues past a font size that fails to load (and logs it) instead ofbreaking and silently skipping the rest.last_changedtimestamps to UTC, avoiding aTypeErrorfrom aware-vs-naive subtraction at render time; theDataProviderprotocol docstring documents the expectation.load_imagenow warns once (not every frame) when it has to create a throwawayaiohttp.ClientSession, nudging the HA integration to pass its shared session for connection pooling / DNS caching.Tests
Adds unit tests for the pixel snapshot matcher (same pixels / different bytes → match; different pixels or size → no match; non-image → byte fallback),
warmupcontinuing past a failing size, the file-handle release on file load, and the naive-timestamp plot path.Note
The naive-timestamp normalization touches
elements/visualizations.py, which the separate plot-correctness PR also touches (different lines — no conflict expected).🤖 Generated with Claude Code