summaryrefslogtreecommitdiff
path: root/tests/unit/misc/test_editor.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/misc/test_editor.py')
-rw-r--r--tests/unit/misc/test_editor.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/unit/misc/test_editor.py b/tests/unit/misc/test_editor.py
index cd21308f8..8e5597a0e 100644
--- a/tests/unit/misc/test_editor.py
+++ b/tests/unit/misc/test_editor.py
@@ -148,6 +148,17 @@ class TestFileHandling:
assert msg.text.startswith("Failed to create initial file: ")
assert editor._proc is None
+ def test_encode_error(self, message_mock, editor, caplog, config_stub):
+ """Test file handling when the initial text can't be encoded."""
+ config_stub.val.editor.encoding = 'ascii'
+
+ with caplog.at_level(logging.ERROR):
+ editor.edit("fooƤbar")
+
+ msg = message_mock.getmsg(usertypes.MessageLevel.error)
+ assert msg.text.startswith("Failed to create initial file: ")
+ assert editor._proc is None
+
def test_double_edit(self, editor):
editor.edit("")
with pytest.raises(ValueError):