parameters: (replacement, target_mod, func_name)
docstring: Patch func_name in target_mod with replacement
  
      Important - original must be resolved by name to avoid
      patching an already patched function.
docstring_summary: Patch func_name in target_mod with replacement
docstring_tokens: Patch func_name in target_mod with replacement
function: def patch_func(replacement, target_mod, func_name):
      """
      Patch func_name in target_mod with replacement
  
      Important - original must be resolved by name to avoid
      patching an already patched function.
      """
      original = getattr(target_mod, func_name)
  
      # set the 'unpatched' attribute on the replacement to
      # point to the original.
      vars(replacement).setdefault('unpatched', original)
  
      # replace the function in the original module
      setattr(target_mod, func_name, replacement)
function_tokens: def patch_func ( replacement , target_mod , func_name ) : original = getattr ( target_mod , func_name ) # set the 'unpatched' attribute on the replacement to # point to the original. vars ( replacement ) . setdefault ( 'unpatched' , original ) # replace the function in the original module setattr ( target_mod , func_name , replacement )