

def decorator_with_introspection(func):
    '\n    Given a function and a decorator\n    (a function with a function as an argument that returns a wrapped/wrapper function),\n    apply the decorator to the function (i.e. return the decorated function)\n    without affecting the ability to perform introspection on the original function, i.e. check its name,\n    signature (argument count), source, etc.\n    '

    def decorator(function):

        def double_wrapper(*args):
            return (function(*args) * 2)
        return double_wrapper

    def function_with_a_name(a, b, c, d):
        return (((a + b) + c) + d)
    wrapped = func(function_with_a_name, decorator)
    assertEqual(wrapped(1, 2, 3, 4), 20)
    assertEqual(wrapped.__name__, 'function_with_a_name')
    assertEqual(wrapped.func_code.co_argcount, 4)
    assertIn('# insert comment here', inspect.getsource(wrapped))

dataset/ETHPy150Open alexmojaki/funcfinder/funcfinder/questions/decorator.py decorator_with_introspection/original