code: def capwarn(self, pytester: Pytester):
      class CapturedWarnings:
          captured: List[
              Tuple[
                  warnings.WarningMessage,
                  Optional[Tuple[str, int, str]],
              ]
          ] = []
  
          @classmethod
          def pytest_warning_recorded(
              cls, warning_message, when, nodeid, location
          ):
              cls.captured.append((warning_message, location))
  
      pytester.plugins = [CapturedWarnings()]
  
      return CapturedWarnings
  
imports: import os
  import sys
  import warnings
  from typing import List
  from typing import Optional
  from typing import Tuple
  import pytest
  from _pytest.fixtures import FixtureRequest
  from _pytest.pytester import Pytester
label_desc: Use image node_id 1 for calling the TestStackLevel obj's underlying member method code with example usage: obj.capwarn(pytester) and returns: CapturedWarnings