code: def test_root_logger_affected(pytester: Pytester) -> None:
      pytester.makepyfile(
          """
          import logging
          logger = logging.getLogger()
  
          def test_foo():
              logger.info('info text ' + 'going to logger')
              logger.warning('warning text ' + 'going to logger')
              logger.error('error text ' + 'going to logger')
  
              assert 0
      """
      )
      log_file = str(pytester.path.joinpath("pytest.log"))
      result = pytester.runpytest(
          "--log-level=ERROR", "--log-file=pytest.log"
      )
      assert result.ret == 1
  
      # The capture log calls in the stdout section only contain the
      # logger.error msg, because of --log-level=ERROR.
      result.stdout.fnmatch_lines(["*error text going to logger*"])
      stdout = result.stdout.str()
      assert "warning text going to logger" not in stdout
      assert "info text going to logger" not in stdout
  
      # The log file should only contain the error log messages and
      # not the warning or info ones, because the root logger is set to
      # ERROR using --log-level=ERROR.
      assert os.path.isfile(log_file)
      with open(log_file, encoding="utf-8") as rfh:
          contents = rfh.read()
          assert "info text going to logger" not in contents
          assert "warning text going to logger" not in contents
          assert "error text going to logger" in contents
  
imports: import io
  import os
  import re
  from typing import cast
  import pytest
  from _pytest.capture import CaptureManager
  from _pytest.config import ExitCode
  from _pytest.fixtures import FixtureRequest
  from _pytest.pytester import Pytester
  from _pytest.terminal import TerminalReporter
label_desc: Use image node_id 3 for calling a global function with example usage: test_root_logger_affected(pytester) without return types