code: def test_wrap_session_exit_sessionfinish(
      returncode: Optional[int], pytester: Pytester
  ) -> None:
      pytester.makeconftest(
          """
          import pytest
          def pytest_sessionfinish():
              pytest.exit(reason="exit_pytest_sessionfinish", returncode={returncode})
      """.format(
              returncode=returncode
          )
      )
      result = pytester.runpytest()
      if returncode:
          assert result.ret == returncode
      else:
          assert result.ret == ExitCode.NO_TESTS_COLLECTED
      assert result.stdout.lines[-1] == "collected 0 items"
      assert result.stderr.lines == ["Exit: exit_pytest_sessionfinish"]
  
imports: import argparse
  import os
  import re
  import sys
  from pathlib import Path
  from typing import Optional
  import pytest
  from _pytest.config import ExitCode
  from _pytest.config import UsageError
  from _pytest.main import resolve_collection_argument
  from _pytest.main import validate_basetemp
  from _pytest.pytester import Pytester
label_desc: Use image node_id 2 for calling a global function with example usage: test_wrap_session_exit_sessionfinish(returncode, pytester) without return types