Fix test_render_raster_layers brittle base64 assertions #313#314
Fix test_render_raster_layers brittle base64 assertions #313#314Tejasv-Singh wants to merge 2 commits intomesa:mainfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #314 +/- ##
=======================================
Coverage 78.09% 78.09%
=======================================
Files 10 10
Lines 995 995
Branches 158 158
=======================================
Hits 777 777
Misses 177 177
Partials 41 41 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
for more information, see https://pre-commit.ci
|
Hey @EwoutH and @wang-boyu! It looks like I was working on this at the exact same time PR #311 was merged. I've resolved the merge conflicts on my end. My PR fixes the #313 issue by doing a semantic pixel check using PIL.Image rather than mocking the encoder. Let me know if you prefer this semantic validation approach and want to review this, or if you are fully happy with the mock approach merged in #311, in which case I can just go ahead and close this PR! |
Summary
Fixes frail rendering tests on Windows with Python 3.14.
tests/test_MapModule.py::TestMapModule::test_render_raster_layerswas asserting a strict match to statically hardcoded base64 PNG data-url representations which fundamentally differ acrosszlibimplementations.Bug / Issue
Resolves #313
Relates to #311
The test_render_raster_layers test failed on Windows/Python 3.14 because the
zlib-ngcompressor (native to Py3.14 on Windows) outputs valid structural DEFLATE strings that objectively do not match byte-for-byte to the hardcoded dictionary strings being strictly mapped viaassertDictEqual. In reality, the rendering was visually identical but algorithmically compressed differently.Implementation
data:image/png;base64,).base64, io andPIL.Image(Pillow) to decode the base64 URL bytes into proper physical memory blocks representing the expected1x1size map layers.getpixel((0,0))values mapping back to natively checking RGBA matrix constraints (e.g., (255, 255, 255, 255) and (0, 0, 0, 255)) instead of strictly enforcing raw string hashes.Testing
.venv/bin/pytest tests/test_MapModule.pylocally on the Windows/Python 3.14 equivalence target and achieved deterministic success (100%) compared to previous CI framework failures.Do let me know if it needs more improvements or any modifications 🙌