fix(memory): clean atomic write test hygiene
Made-with: Cursor
This commit is contained in:
@@ -170,18 +170,13 @@ class TestHistoryWithCursor:
|
|||||||
tmp_path_obj = store.history_file.with_suffix(".jsonl.tmp")
|
tmp_path_obj = store.history_file.with_suffix(".jsonl.tmp")
|
||||||
|
|
||||||
# Mock os.replace to raise an exception
|
# Mock os.replace to raise an exception
|
||||||
original_replace = __import__('os').replace
|
|
||||||
|
|
||||||
def failing_replace(*args, **kwargs):
|
def failing_replace(*args, **kwargs):
|
||||||
raise RuntimeError("Simulated failure")
|
raise RuntimeError("Simulated failure")
|
||||||
|
|
||||||
monkeypatch.setattr('os.replace', failing_replace)
|
monkeypatch.setattr('os.replace', failing_replace)
|
||||||
|
|
||||||
try:
|
with pytest.raises(RuntimeError):
|
||||||
store._write_entries(entries)
|
store._write_entries(entries)
|
||||||
assert False, "Should have raised"
|
|
||||||
except RuntimeError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Temp file should be cleaned up
|
# Temp file should be cleaned up
|
||||||
assert not tmp_path_obj.exists()
|
assert not tmp_path_obj.exists()
|
||||||
|
|||||||
Reference in New Issue
Block a user