Files
AnyPS5/tools/tests/test_progress_render_sliver.py
GalaxyGamingFRandClaude Fable 5.1 a89aa5c0d0 fix(progress): skip cells for rectangles without area
When squarify gave a group a sliver narrower than 2px, treemap passed cells a zero or negative width, so the row count became complex or divided by zero and render crashed. cells now returns no cells for rectangles without area. A regression test renders a 300 and 1 item split.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V9UU71SP1UKGR51Sowbgmq
2026-10-11 12:00:10 -07:00

25 lines
923 B
Python

import importlib.util
import unittest
from pathlib import Path
SPEC = importlib.util.spec_from_file_location("progress", Path(__file__).resolve().parents[1] / "progress.py")
progress = importlib.util.module_from_spec(SPEC)
SPEC.loader.exec_module(progress)
class ProgressRenderSliverTests(unittest.TestCase):
def test_render_with_sliver_group(self):
libraries = {"done": 301, "total": 301, "percent": 100, "groups": [
{"name": "libA", "label": "libA", "done": 300, "todo": 0},
{"name": "libB", "label": "libB", "done": 1, "todo": 0}]}
shaders = {"done": 0, "total": 0, "percent": 0, "groups": []}
self.assertIn("<svg", progress.render(libraries, shaders))
def test_cells_without_area(self):
self.assertEqual(progress.cells(5, 0, 0, 0, 10), [])
self.assertEqual(progress.cells(5, 0, 0, -1, 10), [])
if __name__ == "__main__":
unittest.main()