'Test with a mock and a failing open().'

def test_mock_open_error(self, qsavefile_mock):

    qsavefile_mock.open.return_value = False
    qsavefile_mock.errorString.return_value = 'Hello    World'
    with pytest.raises(OSError, match='Hello    World'):
        with qtutils.savefile_open('filename'):
            pass
    qsavefile_mock.open.assert_called_once_with(QIODevice.WriteOnly)
    qsavefile_mock.cancelWriting.assert_called_once_with()
