From 16f9ddeb13f6bf73c31d105a390bde43cf47ad57 Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Sat, 26 Sep 2026 17:44:52 +0200 Subject: [PATCH] Keep the test suite's JSONL log out of the live events.jsonl _logging_setup attaches its JSONL sink the first time an entry point's main() runs, and the conftest never redirected LOG_JSONL_FILE or LOG_DEDUPE_FILE. Every suite run appended ~25 fixture warnings ("Synced alarm out of range: 24:0") to ~/.local/state/wake_alarm/events.jsonl, the log a failed wake-up is reconstructed from. Patch _logging_setup's names (it imported them by value) in the autouse _hermetic fixture. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0188kZdx3bb56QM8JFUnbHuM --- wake_alarm/tests/conftest.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/wake_alarm/tests/conftest.py b/wake_alarm/tests/conftest.py index ccc8a1f..7be7bf7 100644 --- a/wake_alarm/tests/conftest.py +++ b/wake_alarm/tests/conftest.py @@ -14,6 +14,11 @@ an inhibitor: per-file redirect is exactly the kind that gets forgotten when a new writer appears, and the failure is silent -- a green suite that quietly stamped the live state file. +* ``_logging_setup`` attaches a JSONL sink to the root logger the first time + any entry point's ``main()`` runs, pointed at the real + ``~/.local/state/wake_alarm/events.jsonl``. Unredirected, every suite run + appended fixture warnings ("Synced alarm out of range: 24:0") to the log a + failed wake-up is reconstructed from. """ from __future__ import annotations @@ -37,6 +42,10 @@ def _hermetic(tmp_path: Path) -> Generator[None]: with ( patch("gatelock.log_integrity.DEFAULT_HMAC_KEY_FILE", key_file), patch("wake_alarm._state.WAKE_STATE_FILE", tmp_path / "wake_state.json"), + # _logging_setup imported these by value, so patch its names, not + # _constants'. + patch("wake_alarm._logging_setup.LOG_JSONL_FILE", tmp_path / "events.jsonl"), + patch("wake_alarm._logging_setup.LOG_DEDUPE_FILE", tmp_path / "last.json"), patch( "wake_alarm._session.MORNING_SESSION_FILE", tmp_path / "morning_session.json",