class_docstr: A context manager to record raised warnings.
  
  Adapted from `warnings.catch_warnings`.
class_docstr_tok: ["A","context","manager","to","record","raised","warnings",".","Adapted","from","`","warnings.catch_warnings","`","."]
code: def __enter__(self):
      if self._entered:
          __tracebackhide__ = True
          raise RuntimeError("Cannot enter %r twice" % self)
      self._list = super(WarningsRecorder, self).__enter__()
      warnings.simplefilter("always")
      # python3 keeps track of a "filter version", when the filters are
      # updated previously seen warnings can be re-warned.  python2 has no
      # concept of this so we must reset the warnings registry manually.
      # trivial patching of `warnings.warn` seems to be enough somehow?
      if six.PY2:
  
          def warn(message, category=None, stacklevel=1):
              # duplicate the stdlib logic due to
              # bad handing in the c version of warnings
              if isinstance(message, Warning):
                  category = message.__class__
              # Check category argument
              if category is None:
                  category = UserWarning
              assert issubclass(category, Warning)
  
              # emulate resetting the warn registry
              f_globals = sys._getframe(stacklevel).f_globals
              if "__warningregistry__" in f_globals:
                  orig = f_globals["__warningregistry__"]
                  f_globals["__warningregistry__"] = None
                  try:
                      return self._saved_warn(
                          message, category, stacklevel + 1
                      )
                  finally:
                      f_globals["__warningregistry__"] = orig
              else:
                  return self._saved_warn(
                      message, category, stacklevel + 1
                  )
  
          warnings.warn, self._saved_warn = warn, warnings.warn
      return self
  
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 8 for calling the WarningsRecorder obj's underlying member method code with example usage: obj.__enter__() and returns: self, self, self