Skip to content

Commit 395c4d5

Browse files
Yoshihiro TakaharaYoshihiro Takahara
authored andcommitted
test: Add test for environment validation error during initialization
1 parent ad9eab7 commit 395c4d5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/test_text_editor.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,3 +889,20 @@ def mock_open(*args, **kwargs):
889889
assert "Failed to write file" in result["reason"]
890890
assert test_file.read_text() == "original content\n" # File should be unchanged
891891
editor._validate_environment()
892+
893+
894+
@pytest.mark.asyncio
895+
async def test_initialization_with_environment_error(monkeypatch):
896+
"""Test TextEditor initialization when environment validation fails."""
897+
898+
def mock_validate_environment(self):
899+
raise EnvironmentError("Failed to validate environment")
900+
901+
# Patch the _validate_environment method
902+
monkeypatch.setattr(TextEditor, "_validate_environment", mock_validate_environment)
903+
904+
# Verify that initialization fails with the expected error
905+
with pytest.raises(EnvironmentError) as excinfo:
906+
TextEditor()
907+
908+
assert "Failed to validate environment" in str(excinfo.value)

0 commit comments

Comments
 (0)