code: def warns(expected_warning, *args, **kwargs):
      r"""Assert that code raises a particular class of warning.
  
      Specifically, the parameter ``expected_warning`` can be a warning class or
      sequence of warning classes, and the inside the ``with`` block must issue a warning of that class or
      classes.
  
      This helper produces a list of :class:`warnings.WarningMessage` objects,
      one for each warning raised.
  
      This function can be used as a context manager, or any of the other ways
      ``pytest.raises`` can be used::
  
          >>> with warns(RuntimeWarning):
          ...    warnings.warn("my warning", RuntimeWarning)
  
      In the context manager form you may use the keyword argument ``match`` to assert
      that the exception matches a text or regex::
  
          >>> with warns(UserWarning, match='must be 0 or None'):
          ...     warnings.warn("value must be 0 or None", UserWarning)
  
          >>> with warns(UserWarning, match=r'must be \d+$'):
          ...     warnings.warn("value must be 42", UserWarning)
  
          >>> with warns(UserWarning, match=r'must be \d+$'):
          ...     warnings.warn("this is not here", UserWarning)
          Traceback (most recent call last):
            ...
          Failed: DID NOT WARN. No warnings of type ...UserWarning... was emitted...
  
      """
      __tracebackhide__ = True
      if not args:
          match_expr = kwargs.pop("match", None)
          if kwargs:
              warnings.warn(
                  PYTEST_WARNS_UNKNOWN_KWARGS.format(
                      args=sorted(kwargs)
                  ),
                  stacklevel=2,
              )
          return WarningsChecker(
              expected_warning, match_expr=match_expr
          )
      elif isinstance(args[0], str):
          warnings.warn(WARNS_EXEC, stacklevel=2)
          (code,) = args
          assert isinstance(code, str)
          frame = sys._getframe(1)
          loc = frame.f_locals.copy()
          loc.update(kwargs)
  
          with WarningsChecker(expected_warning):
              code = _pytest._code.Source(code).compile()
              exec(code, frame.f_globals, loc)
      else:
          func = args[0]
          with WarningsChecker(expected_warning):
              return func(*args[1:], **kwargs)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import inspect
  import re
  import sys
  import warnings
  import six
  import _pytest._code
  from _pytest.deprecated import PYTEST_WARNS_UNKNOWN_KWARGS
  from _pytest.deprecated import WARNS_EXEC
  from _pytest.fixtures import yield_fixture
  from _pytest.outcomes import fail
label_desc: Use image node_id 3 for calling a global function with example usage: warns(expected_warning) and returns: WarningsChecker, func