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.
This commit is contained in:
+10
-3
@@ -577,11 +577,18 @@ def test_engine_overlapping_snapshot_uses_latest_start() -> None:
|
|||||||
|
|
||||||
|
|
||||||
def test_engine_override_lists_are_frozen() -> None:
|
def test_engine_override_lists_are_frozen() -> None:
|
||||||
"""The overrides snapshot must be truly read-only: mutating the
|
"""The overrides snapshot must be truly read-only: the engine is
|
||||||
caller's list after construction must not change answers."""
|
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)
|
entry = PresenceOverride(1, "2026-01-06", "2026-01-06", False)
|
||||||
entries = [entry]
|
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
|
assert engine.is_present(1, datetime.date(2026, 1, 6)) is False
|
||||||
entries.append(PresenceOverride(1, "2026-01-07", "2026-01-07", False))
|
entries.append(PresenceOverride(1, "2026-01-07", "2026-01-07", False))
|
||||||
# The late append must NOT change the engine's answers...
|
# The late append must NOT change the engine's answers...
|
||||||
|
|||||||
Reference in New Issue
Block a user