code: def test_tmp_path_factory_fixes_up_world_readable_permissions(
      tmp_path: Path, monkeypatch: MonkeyPatch
  ) -> None:
      """Verify that if a /tmp/pytest-of-foo directory already exists with
      world-readable permissions, it is fixed.
  
      pytest used to mkdir with such permissions, that's why we fix it up.
      """
      # Use the test's tmp_path as the system temproot (/tmp).
      monkeypatch.setenv("PYTEST_DEBUG_TEMPROOT", str(tmp_path))
      tmp_factory = TempPathFactory(
          None, 3, "all", lambda *args: None, _ispytest=True
      )
      basetemp = tmp_factory.getbasetemp()
  
      # Before - simulate bad perms.
      os.chmod(basetemp.parent, 0o777)
      assert (basetemp.parent.stat().st_mode & 0o077) != 0
  
      tmp_factory = TempPathFactory(
          None, 3, "all", lambda *args: None, _ispytest=True
      )
      basetemp = tmp_factory.getbasetemp()
  
      # After - fixed.
      assert (basetemp.parent.stat().st_mode & 0o077) == 0
  
imports: import dataclasses
  import os
  import stat
  import sys
  import warnings
  from pathlib import Path
  from typing import Callable
  from typing import cast
  from typing import List
  from typing import Union
  import pytest
  from _pytest import pathlib
  from _pytest.config import Config
  from _pytest.monkeypatch import MonkeyPatch
  from _pytest.pathlib import cleanup_numbered_dir
  from _pytest.pathlib import create_cleanup_lock
  from _pytest.pathlib import make_numbered_dir
  from _pytest.pathlib import maybe_delete_a_numbered_dir
  from _pytest.pathlib import on_rm_rf_error
  from _pytest.pathlib import register_cleanup_lock_removal
  from _pytest.pathlib import rm_rf
  from _pytest.pytester import Pytester
  from _pytest.tmpdir import get_user
  from _pytest.tmpdir import TempPathFactory
label_desc: Use image node_id 15 for calling a global function with example usage: test_tmp_path_factory_fixes_up_world_readable_permissions(tmp_path, monkeypatch) without return types