code: def test_as_contextmanager(self) -> None:
      with pytest.warns(RuntimeWarning):
          warnings.warn("runtime", RuntimeWarning)
  
      with pytest.warns(UserWarning):
          warnings.warn("user", UserWarning)
  
      with pytest.warns():
          with pytest.raises(pytest.fail.Exception) as excinfo:
              with pytest.warns(RuntimeWarning):
                  warnings.warn("user", UserWarning)
      excinfo.match(
          r"DID NOT WARN. No warnings of type \(.+RuntimeWarning.+,\) were emitted.\n"
          r" Emitted warnings: \[UserWarning\('user',?\)\]."
      )
  
      with pytest.warns():
          with pytest.raises(pytest.fail.Exception) as excinfo:
              with pytest.warns(UserWarning):
                  warnings.warn("runtime", RuntimeWarning)
      excinfo.match(
          r"DID NOT WARN. No warnings of type \(.+UserWarning.+,\) were emitted.\n"
          r" Emitted warnings: \[RuntimeWarning\('runtime',?\)]."
      )
  
      with pytest.raises(pytest.fail.Exception) as excinfo:
          with pytest.warns(UserWarning):
              pass
      excinfo.match(
          r"DID NOT WARN. No warnings of type \(.+UserWarning.+,\) were emitted.\n"
          r" Emitted warnings: \[\]."
      )
  
      warning_classes = (UserWarning, FutureWarning)
      with pytest.warns():
          with pytest.raises(pytest.fail.Exception) as excinfo:
              with pytest.warns(warning_classes) as warninfo:
                  warnings.warn("runtime", RuntimeWarning)
                  warnings.warn("import", ImportWarning)
  
      messages = [each.message for each in warninfo]
      expected_str = (
          f"DID NOT WARN. No warnings of type {warning_classes} were emitted.\n"
          f" Emitted warnings: {messages}."
      )
  
      assert str(excinfo.value) == expected_str
  
imports: import warnings
  from typing import List
  from typing import Optional
  from typing import Type
  import pytest
  from _pytest.pytester import Pytester
  from _pytest.recwarn import WarningsRecorder
label_desc: Use image node_id 5 for calling the TestWarns obj's underlying member method code with example usage: obj.test_as_contextmanager() without return types