'Test with a mock and an exception in the block.'

def test_mock_exception(self, qsavefile_mock):

    qsavefile_mock.open.return_value = True
    with pytest.raises(SavefileTestException):
        with qtutils.savefile_open('filename'):
            raise SavefileTestException
    qsavefile_mock.open.assert_called_once_with(QIODevice.WriteOnly)
    qsavefile_mock.cancelWriting.assert_called_once_with()
