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

Method gethookproxy

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

Source from the content-addressed store, hash-verified

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.
733 path = fspath if isinstance(fspath, Path) else Path(fspath)
734 pm = self.config.pluginmanager
735 # Check if we have the common case of running
736 # hooks with all conftest.py files.
737 my_conftestmodules = pm._getconftestmodules(path)
738 remove_mods = pm._conftest_plugins.difference(my_conftestmodules)
739 proxy: pluggy.HookRelay
740 if remove_mods:
741 # One or more conftests are not in use at this path.
742 proxy = FSHookProxy(pm, remove_mods) # type: ignore[assignment]
743 else:
744 # All plugins are active for this fspath.
745 proxy = self.config.hook
746 return proxy
747
748 def _collect_path(
749 self,

Callers 4

_collect_pathMethod · 0.95
pytest_collect_fileFunction · 0.80
ihookMethod · 0.80
test_hook_proxyMethod · 0.80

Calls 2

FSHookProxyClass · 0.85
_getconftestmodulesMethod · 0.80

Tested by 1

test_hook_proxyMethod · 0.64