code: def test_record_by_subclass(self) -> None:
      with pytest.warns(Warning) as record:
          warnings.warn("user", UserWarning)
          warnings.warn("runtime", RuntimeWarning)
  
      assert len(record) == 2
      assert str(record[0].message) == "user"
      assert str(record[1].message) == "runtime"
  
      class MyUserWarning(UserWarning):
          pass
  
      class MyRuntimeWarning(RuntimeWarning):
          pass
  
      with pytest.warns((UserWarning, RuntimeWarning)) as record:
          warnings.warn("user", MyUserWarning)
          warnings.warn("runtime", MyRuntimeWarning)
  
      assert len(record) == 2
      assert str(record[0].message) == "user"
      assert str(record[1].message) == "runtime"
  
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 9 for calling the TestWarns obj's underlying member method code with example usage: obj.test_record_by_subclass() without return types