MCPcopy Create free account
hub / github.com/pytest-dev/pytest / gethookproxy

Method gethookproxy

src/_pytest/main.py:533–553  ·  view source on GitHub ↗
(self, fspath: "os.PathLike[str]")

Source from the content-addressed store, hash-verified

531 return path_ in self._initialpaths
532
533 def gethookproxy(self, fspath: "os.PathLike[str]"):
534 # Optimization: Path(Path(...)) is much slower than isinstance.
535 path = fspath if isinstance(fspath, Path) else Path(fspath)
536 pm = self.config.pluginmanager
537 # Check if we have the common case of running
538 # hooks with all conftest.py files.
539 my_conftestmodules = pm._getconftestmodules(
540 path,
541 self.config.getoption("importmode"),
542 rootpath=self.config.rootpath,
543 )
544 remove_mods = pm._conftest_plugins.difference(my_conftestmodules)
545 if remove_mods:
546 # One or more conftests are not in use at this fspath.
547 from .config.compat import PathAwareHookProxy
548
549 proxy = PathAwareHookProxy(FSHookProxy(pm, remove_mods))
550 else:
551 # All plugins are active for this fspath.
552 proxy = self.config.hook
553 return proxy
554
555 def _recurse(self, direntry: "os.DirEntry[str]") -> bool:
556 if direntry.name == "__pycache__":

Callers 6

_recurseMethod · 0.95
_collectfileMethod · 0.95
finishMethod · 0.45
executeMethod · 0.45
test_hook_proxyMethod · 0.45

Calls 4

PathAwareHookProxyClass · 0.85
FSHookProxyClass · 0.85
_getconftestmodulesMethod · 0.80
getoptionMethod · 0.45

Tested by 2

test_hook_proxyMethod · 0.36