Skip to content

Commit 2ee6e98

Browse files
committed
test(tui): freeze clock in thinking-preview cache equivalence test
The output-equivalence test compared full Console.export_text() across two compose() calls, whose status line embeds elapsed time and token rate. Freeze time.monotonic so the two renders are deterministic and only the cached preview governs the comparison; guards against a rare timing-boundary flake.
1 parent 4baefb7 commit 2ee6e98

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

tests/ui_and_conv/test_streaming_content_block.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,9 +697,16 @@ def counting(preview: str):
697697
block.compose() # pending changed -> recompute
698698
assert len(calls) == 2
699699

700-
def test_stream_mode_cached_preview_matches_uncached_render(self):
700+
def test_stream_mode_cached_preview_matches_uncached_render(self, monkeypatch):
701701
"""Caching is behavior-preserving: composed output is byte-identical to a
702702
fresh (uncached) render of the same reasoning content across ticks."""
703+
from pythinker_code.ui.shell.visualize import _blocks
704+
705+
# Freeze the clock so the elapsed/token-rate status line is identical
706+
# across both compose() calls — the comparison targets the cached preview,
707+
# not wall-clock timing.
708+
monkeypatch.setattr(_blocks.time, "monotonic", lambda: 100.0)
709+
703710
block = _ContentBlock(is_think=True, show_thinking_stream=True)
704711
block.append("**Preparing report generation**")
705712

0 commit comments

Comments
 (0)