test: consolidate repetitive cases across the suite
This commit is contained in:
1 parent
c406024b59
commit
6eccc2859a
31 files changed
+745
-1315
No files matched your search
@@ -71,33 +71,24 @@ class TestHistoryWithCursor:
|
||||
cursor = store.append_history("event 3")
|
||||
assert cursor == 3
|
||||
|
||||
def test_append_history_strips_thinking_content(self, store):
|
||||
"""`strip_think` must run before persistence — well-formed thinking
|
||||
blocks shouldn't land in history."""
|
||||
cursor = store.append_history("<think>reasoning</think>final answer")
|
||||
@pytest.mark.parametrize(
|
||||
"input_text, expected_content",
|
||||
[
|
||||
pytest.param(
|
||||
"<think>reasoning</think>final answer",
|
||||
"final answer",
|
||||
id="strips_thinking_content",
|
||||
),
|
||||
pytest.param("<think>nothing user-facing</think>", "", id="drops_pure_leak_content"),
|
||||
pytest.param("<channel|>", "", id="drops_malformed_leak_prefix"),
|
||||
],
|
||||
)
|
||||
def test_append_history_sanitizes_thinking(self, store, input_text, expected_content):
|
||||
cursor = store.append_history(input_text)
|
||||
content = store.read_file(store.history_file)
|
||||
data = json.loads(content)
|
||||
assert data["cursor"] == cursor
|
||||
assert data["content"] == "final answer"
|
||||
|
||||
def test_append_history_drops_pure_leak_content(self, store):
|
||||
"""Regression: entries that strip down to empty (pure template-token
|
||||
leak) must NOT fall back to the raw leak. Persisting the raw text
|
||||
would re-pollute context via consolidation / replay, undoing the
|
||||
protection `strip_think` provides."""
|
||||
cursor = store.append_history("<think>nothing user-facing</think>")
|
||||
content = store.read_file(store.history_file)
|
||||
data = json.loads(content)
|
||||
assert data["cursor"] == cursor
|
||||
assert data["content"] == ""
|
||||
|
||||
def test_append_history_drops_malformed_leak_prefix(self, store):
|
||||
"""Channel-marker / malformed opening leaks should not survive."""
|
||||
cursor = store.append_history("<channel|>")
|
||||
content = store.read_file(store.history_file)
|
||||
data = json.loads(content)
|
||||
assert data["cursor"] == cursor
|
||||
assert data["content"] == ""
|
||||
assert data["content"] == expected_content
|
||||
|
||||
def test_read_unprocessed_history(self, store):
|
||||
store.append_history("event 1")
|
||||
|
||||
Reference in new issue
Block a user