'Test with a mock and a successful write.'

def test_mock_successful(self, qsavefile_mock):

    qsavefile_mock.open.return_value = True
    qsavefile_mock.errorString.return_value = 'Hello    World'
    qsavefile_mock.commit.return_value = True
    qsavefile_mock.write.side_effect = len
    qsavefile_mock.isOpen.return_value = True
    with qtutils.savefile_open('filename') as f:
        f.write('Hello    World')
    qsavefile_mock.open.assert_called_once_with(QIODevice.WriteOnly)
    assert (not qsavefile_mock.cancelWriting.called)
    qsavefile_mock.write.assert_called_once_with('Hello    World')
