code: def test_removed_in_x_warning_as_error(
      pytester: Pytester, change_default
  ) -> None:
      """This ensures that PytestRemovedInXWarnings raised by pytest are turned into errors.
  
      This test should be enabled as part of each major release, and skipped again afterwards
      to ensure our deprecations are turning into warnings as expected.
      """
      pytester.makepyfile(
          """
          import warnings, pytest
          def test():
              warnings.warn(pytest.PytestRemovedIn9Warning("some warning"))
      """
      )
      if change_default == "ini":
          pytester.makeini(
              """
              [pytest]
              filterwarnings =
                  ignore::pytest.PytestRemovedIn9Warning
          """
          )
  
      args = (
          ("-Wignore::pytest.PytestRemovedIn9Warning",)
          if change_default == "cmdline"
          else ()
      )
      result = pytester.runpytest(*args)
      if change_default is None:
          result.stdout.fnmatch_lines(["* 1 failed in *"])
      else:
          assert change_default in ("ini", "cmdline")
          result.stdout.fnmatch_lines(["* 1 passed 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 17 for calling a global function with example usage: test_removed_in_x_warning_as_error(pytester, change_default) without return types