code: def assert_warns(warning_class, func, *args, **kw):
      """Fail unless a warning of class warning_class is thrown by callable when
      invoked with arguments args and keyword arguments kwargs.
  
      If a different type of warning is thrown, it will not be caught, and the
      test case will be deemed to have suffered an error.
      """
  
      # XXX: once we may depend on python >= 2.6, this can be replaced by the
      # warnings module context manager.
      with WarningManager(record=True) as l:
          warnings.simplefilter("always")
          func(*args, **kw)
          if not len(l) > 0:
              raise AssertionError(
                  "No warning raised when calling %s" % func.__name__
              )
          if not l[0].category is warning_class:
              raise AssertionError(
                  "First warning for %s is not a "
                  "%s( is %s)" % (func.__name__, warning_class, l[0])
              )
  
file_path: catboost/contrib/python/ipython/py2/IPython/external/decorators/_numpy_testing_utils.py
imports: import sys
  import warnings
label_desc: Use image node_id 1 for calling a global function with example usage: assert_warns(warning_class, func) without return types