class_docstr: Helper to conveniently monkeypatch attributes/items/environment
  variables/syspath.
  
  Returned by the :fixture:`monkeypatch` fixture.
  
  .. versionchanged:: 6.2
      Can now also be used directly as `pytest.MonkeyPatch()`, for when
      the fixture is not available. In this case, use
      :meth:`with MonkeyPatch.context() as mp: <context>` or remember to call
      :meth:`undo` explicitly.
docstr: Prepend ``path`` to ``sys.path`` list of import locations.
code: def syspath_prepend(self, path) -> None:
      """Prepend ``path`` to ``sys.path`` list of import locations."""
  
      if self._savesyspath is None:
          self._savesyspath = sys.path[:]
      sys.path.insert(0, str(path))
  
      # https://github.com/pypa/setuptools/blob/d8b901bc/docs/pkg_resources.txt#L162-L171
      # this is only needed when pkg_resources was already loaded by the namespace package
      if "pkg_resources" in sys.modules:
          from pkg_resources import fixup_namespace_packages
  
          fixup_namespace_packages(str(path))
  
      # A call to syspathinsert() usually means that the caller wants to
      # import some dynamically created files, thus with python3 we
      # invalidate its import caches.
      # This is especially important when any namespace package is in use,
      # since then the mtime based FileFinder cache (that gets created in
      # this case already) gets not invalidated when writing the new files
      # quickly afterwards.
      from importlib import invalidate_caches
  
      invalidate_caches()
  
imports: import os
  import re
  import sys
  import warnings
  from contextlib import contextmanager
  from typing import Any
  from typing import final
  from typing import Generator
  from typing import List
  from typing import Mapping
  from typing import MutableMapping
  from typing import Optional
  from typing import overload
  from typing import Tuple
  from typing import TypeVar
  from typing import Union
  from _pytest.fixtures import fixture
  from _pytest.warning_types import PytestWarning
label_desc: Use image node_id 11 for calling the MonkeyPatch obj's underlying member method code with example usage: obj.syspath_prepend(path) without return types