Gets a context for a target function.

    :rtype: caliendo.hooks.Context
    :returns: The context for the call. Patches are applied and removed within a context.

def get_context(method):
    """
    Gets a context for a target function.

    :rtype: caliendo.hooks.Context
    :returns: The context for the call. Patches are applied and removed within a context.
    """
    if Context.exists(method):
        return Context.increment(method)
    else:
        return Context(method)