fix(memory): clean atomic write test hygiene

Made-with: Cursor
This commit is contained in:
Xubin Ren 2026-04-29 08:54:51 +00:00 committed by Xubin Ren
parent 53ca2836e7
commit 3d7099b421
2 changed files with 11 additions and 16 deletions

View File

@ -170,18 +170,13 @@ class TestHistoryWithCursor:
tmp_path_obj = store.history_file.with_suffix(".jsonl.tmp")
# Mock os.replace to raise an exception
original_replace = __import__('os').replace
def failing_replace(*args, **kwargs):
raise RuntimeError("Simulated failure")
monkeypatch.setattr('os.replace', failing_replace)
try:
with pytest.raises(RuntimeError):
store._write_entries(entries)
assert False, "Should have raised"
except RuntimeError:
pass
# Temp file should be cleaned up
assert not tmp_path_obj.exists()