Skip to content

Commit 0b97ecb

Browse files
author
Yoshihiro Takahara
committed
test: Add test_edit_file_contents_io_error for text editor
1 parent c82fa4f commit 0b97ecb

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/test_text_editor.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,3 +394,25 @@ async def test_validate_environment():
394394
editor = TextEditor()
395395
# Currently just verifies it can be called without error
396396
editor._validate_environment()
397+
398+
399+
@pytest.mark.asyncio
400+
async def test_edit_file_contents_io_error(editor, tmp_path):
401+
"""Test editing file with IO error."""
402+
test_file = tmp_path / "io_error_test.txt"
403+
test_file.write_text("test content")
404+
405+
# Make file read-only
406+
test_file.chmod(0o444)
407+
408+
result = await editor.edit_file_contents(
409+
str(test_file),
410+
editor.calculate_hash("test content"),
411+
[{"line_start": 1, "contents": "new content"}],
412+
)
413+
414+
assert result["result"] == "error"
415+
assert "permission denied" in result["reason"].lower()
416+
417+
# Restore permissions for cleanup
418+
test_file.chmod(0o644)

0 commit comments

Comments
 (0)