MCPcopy
hub / github.com/pytest-dev/pytest / isinitpath

Method isinitpath

src/_pytest/main.py:707–729  ·  view source on GitHub ↗

Is path an initial path? An initial path is a path explicitly given to pytest on the command line. :param with_parents: If set, also return True if the path is a parent of an initial path. .. versionchanged:: 8.0 Added the ``with_parents`` p

(
        self,
        path: str | os.PathLike[str],
        *,
        with_parents: bool = False,
    )

Source from the content-addressed store, hash-verified

705 pytest_collectreport = pytest_runtest_logreport
706
707 def isinitpath(
708 self,
709 path: str | os.PathLike[str],
710 *,
711 with_parents: bool = False,
712 ) -> bool:
713 """Is path an initial path?
714
715 An initial path is a path explicitly given to pytest on the command
716 line.
717
718 :param with_parents:
719 If set, also return True if the path is a parent of an initial path.
720
721 .. versionchanged:: 8.0
722 Added the ``with_parents`` parameter.
723 """
724 # Optimization: Path(Path(...)) is much slower than isinstance.
725 path_ = path if isinstance(path, Path) else Path(path)
726 if with_parents:
727 return path_ in self._initialpaths_with_parents
728 else:
729 return path_ in self._initialpaths
730
731 def gethookproxy(self, fspath: os.PathLike[str]) -> pluggy.HookRelay:
732 # Optimization: Path(Path(...)) is much slower than isinstance.

Callers 6

_is_doctestFunction · 0.45
pytest_collect_fileFunction · 0.45
collectMethod · 0.45
collectMethod · 0.45
_should_rewriteMethod · 0.45

Calls

no outgoing calls

Tested by 1

_is_doctestFunction · 0.36