Skip to content

test/chore: compare snapshots by pixels; small resource and robustness fixes#32

Merged
g4bri3lDev merged 1 commit into
OpenDisplay:mainfrom
balloob:chore/tests-and-resources
Jul 6, 2026
Merged

test/chore: compare snapshots by pixels; small resource and robustness fixes#32
g4bri3lDev merged 1 commit into
OpenDisplay:mainfrom
balloob:chore/tests-and-resources

Conversation

@balloob

@balloob balloob commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the brittle visual-snapshot comparison (which fails on main under Pillow 12) plus a handful of small resource/robustness notes.

Findings addressed

  • C1 — visual snapshots compared raw PNG bytes. Every 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 on main under Pillow 12. Added PixelPNGImageSnapshotExtension, which decodes both sides and diffs pixels across all channels (getbbox(alpha_only=False) — the default alpha_only=True would 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).
  • A12 — small resource/API notes:
    • media_loader calls Image.load() for file and HTTP sources, so the file handle is released (no ResourceWarning under -W error) and decoding happens up front instead of lazily mid-composite.
    • warmup now continues past a font size that fails to load (and logs it) instead of breaking and silently skipping the rest.
    • the plot normalizes naive last_changed timestamps to UTC, avoiding a TypeError from aware-vs-naive subtraction at render time; the DataProvider protocol docstring documents the expectation.
  • B9 — session-less HTTP. load_image now warns once (not every frame) when it has to create a throwaway aiohttp.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), warmup continuing 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

…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
@balloob balloob requested a review from g4bri3lDev as a code owner July 4, 2026 07:50
@codecov

codecov Bot commented Jul 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 62.50000% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/odl_renderer/media_loader.py 40.00% 6 Missing ⚠️

📢 Thoughts on this report? Let us know!

@g4bri3lDev g4bri3lDev merged commit b1ec2cf into OpenDisplay:main Jul 6, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants