'DRY helper.  Returns a side effect function for use with mocks that
will be called multiple times, permitting Exceptions to be raised
(or not) in a specified order.
See Also:
http://www.voidspace.org.uk/python/mock/examples.html#multiple-calls-with-different-effects
http://www.voidspace.org.uk/python/mock/mock.html#mock.Mock.side_effect'

def _make_side_effect(self, side_effects):

    def side_effect(*_a):
        if side_effects:
            exc = side_effects.pop(0)
            if exc:
                raise exc
        return mock.DEFAULT
    return side_effect
