code: def skipif(skip_condition, msg=None):
      """
      Make function raise SkipTest exception if a given condition is true.
  
      If the condition is a callable, it is used at runtime to dynamically
      make the decision. This is useful for tests that may require costly
      imports, to delay the cost until the test suite is actually executed.
  
      Parameters
      ----------
      skip_condition : bool or callable
          Flag to determine whether to skip the decorated test.
      msg : str, optional
          Message to give on raising a SkipTest exception. Default is None.
  
      Returns
      -------
      decorator : function
          Decorator which, when applied to a function, causes SkipTest
          to be raised when `skip_condition` is True, and the function
          to be called normally otherwise.
  
      Notes
      -----
      The decorator itself is decorated with the ``nose.tools.make_decorator``
      function in order to transmit function name, and various other metadata.
  
      """
  
      def skip_decorator(f):
          # Local import to avoid a hard nose dependency and only incur the
          # import time overhead at actual test-time.
          import nose
  
          # Allow for both boolean or callable skip conditions.
          if isinstance(skip_condition, collections_abc.Callable):
              skip_val = lambda: skip_condition()
          else:
              skip_val = lambda: skip_condition
  
          def get_msg(func, msg=None):
              """Skip message with information about function being skipped."""
              if msg is None:
                  out = "Test skipped due to test condition"
              else:
                  out = msg
  
              return "Skipping test: %s: %s" % (func.__name__, out)
  
          # We need to define *two* skippers because Python doesn't allow both
          # return with value and yield inside the same function.
          def skipper_func(*args, **kwargs):
              """Skipper for normal test functions."""
              if skip_val():
                  raise SkipTest(get_msg(f, msg))
              else:
                  return f(*args, **kwargs)
  
          def skipper_gen(*args, **kwargs):
              """Skipper for test generators."""
              if skip_val():
                  raise SkipTest(get_msg(f, msg))
              else:
                  for x in f(*args, **kwargs):
                      yield x
  
          # Choose the right skipper to use when building the actual decorator.
          if nose.util.isgenerator(f):
              skipper = skipper_gen
          else:
              skipper = skipper_func
  
          return nose.tools.make_decorator(f)(skipper)
  
      return skip_decorator
  
imports: from __future__ import division, absolute_import, print_function
  from .utils import SkipTest, assert_warns, HAS_REFCOUNT
label_desc: Use image node_id 3 for calling a global function with example usage: skipif(skip_condition, msg) and returns: skip_decorator, nose, unknown, f