code: def pyfile_with_warnings(
      pytester: Pytester, request: FixtureRequest
  ) -> str:
      """Create a test file which calls a function in a module which generates warnings."""
      pytester.syspathinsert()
      test_name = request.function.__name__
      module_name = test_name.lstrip("test_") + "_module"
      test_file = pytester.makepyfile(
          """
          import {module_name}
          def test_func():
              assert {module_name}.foo() == 1
          """.format(
              module_name=module_name
          ),
          **{
              module_name: """
              import warnings
              def foo():
                  warnings.warn(UserWarning("user warning"))
                  warnings.warn(RuntimeWarning("runtime warning"))
                  return 1
              """,
          },
      )
      return str(test_file)
  
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 a global function with example usage: pyfile_with_warnings(pytester, request) and returns: str