testsAndMisc/python_pkg/wake_alarm
Krzysztof kuhy Rudnicki 247607e8c3 Fix the real cause of the wake_alarm CI coverage gap
The previous two fix attempts (removing -n 4 xdist parallelism, ruling
out a Python 3.12-vs-3.14 difference) both targeted the wrong cause for
the coverage gap on _alarm_display.py:71. The actual bug:
_restore_display() was never mocked in the _block_extra_devices fixture
shared by test_alarm_part2/3/4.py, so every test exercising
on_close()/_lock.close() ran the REAL _restore_display(), which calls
the REAL shutil.which('xset'). My dev machine has /usr/bin/xset
installed, so it always hit the "found" branch by accident; the CI
runner doesn't, so it always hit the "missing" branch instead, and
there was no dedicated unit test for the "found" path at all.

Fix: mock _restore_display in that fixture (matching its already-mocked
siblings _restore_fans/_restore_alarm_audio/turn_off_plug), and add a
dedicated, hermetic test for the xset-found branch that doesn't depend
on whether the running machine actually has xset on PATH. Side benefit:
the test suite no longer makes a real `xset s on` subprocess call on
the developer's desktop as an untracked side effect of running tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A7vbgtFfZmfxJtN5DdtJky
2026-06-22 09:14:29 +02:00
..
tests Fix the real cause of the wake_alarm CI coverage gap 2026-06-22 09:14:29 +02:00
__init__.py Add tests and fix pre-commit issues across all projects 2026-04-12 20:45:24 +02:00
_alarm_display.py feat: split oversized modules for 500-line limit, fix kasa coverage gap 2026-06-14 07:19:37 +02:00
_alarm.py Migrate wake_alarm to the shared gatelock backend 2026-06-22 07:33:49 +02:00
_audio.py refactor: split wake_alarm modules, fix ruff violations, enforce global coverage 2026-05-30 22:13:32 +02:00
_challenges.py refactor: split wake_alarm modules, fix ruff violations, enforce global coverage 2026-05-30 22:13:32 +02:00
_constants.py feat: split oversized modules for 500-line limit, fix kasa coverage gap 2026-06-14 07:19:37 +02:00
_smart_plug.py wake_alarm: Tapo P110 plug control, fan ramp via sudo, loud warnings 2026-05-23 19:51:26 +02:00
_state.py Migrate wake_alarm to the shared gatelock backend 2026-06-22 07:33:49 +02:00
install.sh feat: split oversized modules for 500-line limit, fix kasa coverage gap 2026-06-14 07:19:37 +02:00
shutdown-wrapper.sh wake_alarm + midnight_shutdown: hibernate on alarm nights instead of poweroff 2026-05-22 16:01:04 +02:00
sleep-hook.sh morning_routine: unified alarm+lock orchestrator, fix alarm audio/reliability 2026-05-25 18:55:27 +02:00
wake_state.json feat: split oversized modules for 500-line limit, fix kasa coverage gap 2026-06-14 07:19:37 +02:00
wake-alarm-fans.sh wake_alarm: louder + typeable + multi-fan 2026-05-24 16:20:34 +02:00
wake-alarm.service morning_routine: unified alarm+lock orchestrator, fix alarm audio/reliability 2026-05-25 18:55:27 +02:00