From bdf3513609065fdb16af4b12be29466991923954 Mon Sep 17 00:00:00 2001 From: Joshua King Date: Tue, 15 Sep 2026 18:16:40 -0400 Subject: [PATCH] Test fix: build the frozen-snapshot engine on the caller's list Review round 3 (Codex gpt-5.6-terra, LOW): the helper copied the list, so the mutation could never have affected even a shallow snapshot. The engine is now constructed directly on the caller's list, making the freeze regression-proof. Suite green before commit: 997 passed. --- tests/test_presence.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/test_presence.py b/tests/test_presence.py index d08b108..ffcb7c7 100644 --- a/tests/test_presence.py +++ b/tests/test_presence.py @@ -577,11 +577,18 @@ def test_engine_overlapping_snapshot_uses_latest_start() -> None: def test_engine_override_lists_are_frozen() -> None: - """The overrides snapshot must be truly read-only: mutating the - caller's list after construction must not change answers.""" + """The overrides snapshot must be truly read-only: the engine is + built directly on the CALLER's list, so mutating that list after + construction would change answers under a shallow copy — under the + frozen snapshot it must not.""" entry = PresenceOverride(1, "2026-01-06", "2026-01-06", False) entries = [entry] - engine = _engine_with_overrides(*entries) + schedule = PresenceSchedule( + 1, 2, ANCHOR, {0: {0, 1, 2, 3, 4, 5, 6}, 1: set()} + ) + engine = PresenceEngine( + {1: schedule}, overrides={1: entries} # caller-owned list + ) assert engine.is_present(1, datetime.date(2026, 1, 6)) is False entries.append(PresenceOverride(1, "2026-01-07", "2026-01-07", False)) # The late append must NOT change the engine's answers...