code: def testing_hooks_method(method_name):
      """Factory function for making testing methods."""
      if method_name in PIPELINE_HOOKS_CONTEXT_MANAGERS:
          # Generate a method that enters the context of all sub-hooks.
          @wraps(getattr(PipelineHooks, method_name))
          @contextmanager
          def ctx(self, *args, **kwargs):
              call = Call(method_name, args, kwargs)
              self.trace.append(ContextCall("enter", call))
              yield
              self.trace.append(ContextCall("exit", call))
  
          return ctx
  
      else:
          # Generate a method that calls methods of all sub-hooks.
          @wraps(getattr(PipelineHooks, method_name))
          def method(self, *args, **kwargs):
              self.trace.append(Call(method_name, args, kwargs))
  
          return method
  
file_path: zipline/zipline/pipeline/hooks/testing.py
imports: from collections import namedtuple
  from .iface import PipelineHooks, PIPELINE_HOOKS_CONTEXT_MANAGERS
  from interface import implements
  from zipline.utils.compat import contextmanager, wraps
label_desc: Use image node_id 1 for calling a global function with example usage: testing_hooks_method(method_name) and returns: ctx, method