Fix test_backup_error.

- Need caplog at level error
- Rename test to be unique
This commit is contained in:
Ryan Roden-Corrent 2018-03-13 08:50:34 -04:00
parent 27966c94a6
commit 73517f0a51

View File

@ -183,13 +183,14 @@ 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)
with caplog.at_level(logging.ERROR):
editor.backup()
msg = message_mock.getmsg(usertypes.MessageLevel.error)