def decorate(self, fun):
        """Decorate a function for overriding configuration."""
        @wraps(fun)
        def _decorated(*args, **kwargs):
            # Push the config, run the function and pop it afterwards.
            self.push_config()
            try:
                return fun(*args, **kwargs)
            finally:
                self.pop_config()
        return _decorated
Decorate a function for overriding configuration.