fix: survive the screen library's sys.exit, copy all modules into the image, fit -10 degree readouts

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
rickzkmandClaude Sonnet 5.5 committed 2026-10-22 13:38:37 +02:00
1 parent ae8c17d8d5
commit 09f78d1a63
8 files changed
+78 -8

No files matched your search

+25
View File
@@ -138,3 +138,28 @@ def test_render_error_size_and_has_ink():
def test_render_error_long_line_does_not_raise():
assert runner.render_error(["X" * 500]).size == (480, 320)
def test_open_screen_retries_when_the_library_calls_sys_exit():
"""The pinned screen library calls sys.exit(0) when the port is missing; that must not end the process."""
attempts, sleeps = [], []
def factory():
attempts.append(1)
if len(attempts) < 3:
raise SystemExit(0)
return "lcd"
assert runner.open_screen(factory, running=lambda: True, sleep=sleeps.append) == "lcd"
assert sleeps == [30.0, 30.0]
def test_run_counts_library_sys_exit_as_a_failed_draw():
class ExitingLcd:
def DisplayPILImage(self, *a, **k):
raise SystemExit(0)
view = StubView(lambda now: "same")
with pytest.raises(SystemExit): # after max_failures; Docker then restarts and open_screen retries
runner.run(view, ExitingLcd(), now_fn=clock(T0, 0), running=ticks(50), sleep=lambda s: None, max_failures=3)
assert view.renders == 3 # it tried three times first