def construct_new_test_function(original_func, name, build_params):
    new_func = types.FunctionType(
        six.get_function_code(original_func),
        six.get_function_globals(original_func),
        name=name,
        argdefs=six.get_function_defaults(original_func)
    )

    # Support either an arg list or kwarg dict for our data
    build_args = build_params if isinstance(build_params, list) else []
    build_kwargs = build_params if isinstance(build_params, dict) else {}

    # Build a test wrapper to execute with our kwargs
    def test_wrapper(func, test_args, test_kwargs):
        @functools.wraps(func)
        def wrapper(self):
            return func(self, *test_args, **test_kwargs)
        return wrapper

    return test_wrapper(new_func, build_args, build_kwargs)
Do actual heartbeat
dataset/ETHPy150Open openstack/python-barbicanclient/functionaltests/utils.py/construct_new_test_function--crossover with--dataset/ETHPy150Open selfsk/nodeset.core/src/nodeset/core/heartbeat.py/NodeHeartBeat._do_heartbeat