code: def test_as_errors(
      pytester: Pytester, pyfile_with_warnings, method
  ) -> None:
      args = ("-W", "error") if method == "cmdline" else ()
      if method == "ini":
          pytester.makeini(
              """
              [pytest]
              filterwarnings=error
              """
          )
      # Use a subprocess, since changing logging level affects other threads
      # (xdist).
      result = pytester.runpytest_subprocess(
          *args, pyfile_with_warnings
      )
      result.stdout.fnmatch_lines(
          [
              "E       UserWarning: user warning",
              "as_errors_module.py:3: UserWarning",
              "* 1 failed in *",
          ]
      )
  
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 4 for calling a global function with example usage: test_as_errors(pytester, pyfile_with_warnings, method) without return types