File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -889,3 +889,20 @@ def mock_open(*args, **kwargs):
889
889
assert "Failed to write file" in result ["reason" ]
890
890
assert test_file .read_text () == "original content\n " # File should be unchanged
891
891
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 )
You can’t perform that action at this time.
0 commit comments