From 73517f0a51f6f64bc9c2cf7c8508b1e7f12d7185 Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Tue, 13 Mar 2018 08:50:34 -0400 Subject: [PATCH] Fix test_backup_error. - Need caplog at level error - Rename test to be unique --- tests/unit/misc/test_editor.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/unit/misc/test_editor.py b/tests/unit/misc/test_editor.py index 095f00ef2..94021484a 100644 --- a/tests/unit/misc/test_editor.py +++ b/tests/unit/misc/test_editor.py @@ -183,14 +183,15 @@ class TestFileHandling: # content has not changed, so no backup should be created assert not message_mock.messages - def test_backup(self, qtbot, message_mock, mocker): + def test_backup_error(self, qtbot, message_mock, mocker, caplog): editor = editormod.ExternalEditor(watch=True) editor.edit('foo') with qtbot.wait_signal(editor.file_updated): _update_file(editor._filename, 'bar') mocker.patch('tempfile.NamedTemporaryFile', side_effect=OSError) - editor.backup() + with caplog.at_level(logging.ERROR): + editor.backup() msg = message_mock.getmsg(usertypes.MessageLevel.error) assert msg.text.startswith('Failed to create editor backup:')