def _set_signature(mock, original, skipfirst):
    # creates a function with signature (*args, **kwargs) that delegates to a
    # mock. It still does signature checking by calling a lambda with the same
    # signature as the original. This is effectively mocksignature2.
    if not _callable(original):
        return

    skipfirst = isinstance(original, ClassTypes)
    result = _getsignature2(original, skipfirst)
    if result is None:
        # was a C function (e.g. object().__init__ ) that can't be mocked
        return

    signature, func = result

    src = "lambda %s: None" % signature
    context = {'_mock_': mock}
    checksig = eval(src, context)
    _copy_func_details(func, checksig)

    name = original.__name__
    import keyword
    if not _isidentifier(name):
        name = funcopy
    context = {'checksig': checksig, 'mock': mock}
    src = """def %s(*args, **kwargs):
    checksig(*args, **kwargs)
    return mock(*args, **kwargs)""" % name
    exec (src, context)
    funcopy = context[name]
    _setup_func(funcopy, mock)
    return funcopy
dataset/ETHPy150Open sibson/vncdotool/tests/unit/mock.py/_set_signature/original