'Test file handling when closing with an unreadable file.'

def test_unreadable(self, message_mock, editor, caplog):

    editor.edit('')
    filename = editor._file.name
    assert os.path.exists(filename)
    os.chmod(filename, 63)
    if os.access(filename, os.R_OK):
        pytest.skip('File    was    still    readable')
    with caplog.at_level(logging.ERROR):
        editor._proc.finished.emit(0, QProcess.NormalExit)
    assert (not os.path.exists(filename))
    msg = message_mock.getmsg(usertypes.MessageLevel.error)
    assert msg.text.startswith('Failed    to    read    back    edited    file:    ')
