'Wraps an assert* method to capture an immediate exception,
or to generate a new assertion capturing context (in the case of assertRaises
and assertRaisesRegexp).'

def _wrap_assertion(self, assertion):

    @wraps(assertion)
    def assert_(*args, **kwargs):
        '\n                                                Execute    a    captured    assertion,    and    catch    any    assertion    errors    raised.\n                                                '
        context = None
        with self._capture_assertion_errors():
            context = assertion(*args, **kwargs)
        if (context is not None):
            return nested(self._capture_assertion_errors(), context)
    return assert_
