import functools


def noop_if_no_unpatch(f):
    """
    A helper for PatchTestCase test methods that will no-op the test if the
    __unpatch_func__ attribute is None
    """
    @functools.wraps(f)
    def wrapper(self, *args, **kwargs):
        if getattr(self, '__unpatch_func__') is None:
            return
        return f(self, *args, **kwargs)
    return wrapper