@staticmethod
    def test_wrapper(cls, func):

        def wrapper(self, *args, **kwargs):
            try:
                func(self, *args, **kwargs)
            except UnexpectedCall as e:
                # if this is not python3, use python2 syntax
                if not hasattr(e, '__traceback__'):
                    from .python2 import reraise
                    reraise(
                        AssertionError, '\n\n' + str(e), sys.exc_info()[-1])
                exc = AssertionError('\n\n' + str(e))
                setattr(exc, '__traceback__', sys.exc_info()[-1])
                raise exc
            finally:
                # Teardown all stubs so that if anyone stubbed methods that
                # would be called during exception handling (e.g. "open"),
                # the original method is used. Without, recursion limits are
                # common with little insight into what went wrong.
                exceptions = []
                try:
                    for s in self._stubs:
                        # Make sure we collect any unmet expectations before
                        # teardown.
                        exceptions.extend(s.unmet_expectations())
                        s.teardown()
                except:
                    # A rare case where this is about the best that can be
                    # done, as we don't want to supersede the actual
                    # exception if there is one.
                    traceback.print_exc()

            if exceptions:
                raise ExpectationNotSatisfied(*exceptions)

        wrapper.__name__ = func.__name__
        wrapper.__doc__ = func.__doc__
        wrapper.__module__ = func.__module__
        wrapper.__wrapped__ = func
        if getattr(func, '__unittest_skip__', False):
            wrapper.__unittest_skip__ = True
            wrapper.__unittest_skip_why__ = func.__unittest_skip_why__
        return wrapper
Set a bunch of values in the cache at once from a dict of key/value
dataset/ETHPy150Open agoragames/chai/chai/chai.py/ChaiTestType.test_wrapper--crossover with--dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.2/django/core/cache/backends/base.py/BaseCache.set_many