typing: FSHookProxy/gethookproxy
Taken out of https://github.com/pytest-dev/pytest/pull/6556.
This commit is contained in:
parent
e2934c3f8c
commit
ae5d16be10
|
@ -436,7 +436,7 @@ class Session(nodes.FSCollector):
|
||||||
def isinitpath(self, path):
|
def isinitpath(self, path):
|
||||||
return path in self._initialpaths
|
return path in self._initialpaths
|
||||||
|
|
||||||
def gethookproxy(self, fspath):
|
def gethookproxy(self, fspath: py.path.local):
|
||||||
return super()._gethookproxy(fspath)
|
return super()._gethookproxy(fspath)
|
||||||
|
|
||||||
def perform_collect(self, args=None, genitems=True):
|
def perform_collect(self, args=None, genitems=True):
|
||||||
|
|
|
@ -19,6 +19,7 @@ from _pytest.compat import cached_property
|
||||||
from _pytest.compat import getfslineno
|
from _pytest.compat import getfslineno
|
||||||
from _pytest.compat import TYPE_CHECKING
|
from _pytest.compat import TYPE_CHECKING
|
||||||
from _pytest.config import Config
|
from _pytest.config import Config
|
||||||
|
from _pytest.config import PytestPluginManager
|
||||||
from _pytest.fixtures import FixtureDef
|
from _pytest.fixtures import FixtureDef
|
||||||
from _pytest.fixtures import FixtureLookupError
|
from _pytest.fixtures import FixtureLookupError
|
||||||
from _pytest.fixtures import FixtureLookupErrorRepr
|
from _pytest.fixtures import FixtureLookupErrorRepr
|
||||||
|
@ -394,12 +395,14 @@ def _check_initialpaths_for_relpath(session, fspath):
|
||||||
|
|
||||||
|
|
||||||
class FSHookProxy:
|
class FSHookProxy:
|
||||||
def __init__(self, fspath, pm, remove_mods):
|
def __init__(
|
||||||
|
self, fspath: py.path.local, pm: PytestPluginManager, remove_mods
|
||||||
|
) -> None:
|
||||||
self.fspath = fspath
|
self.fspath = fspath
|
||||||
self.pm = pm
|
self.pm = pm
|
||||||
self.remove_mods = remove_mods
|
self.remove_mods = remove_mods
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name: str):
|
||||||
x = self.pm.subset_hook_caller(name, remove_plugins=self.remove_mods)
|
x = self.pm.subset_hook_caller(name, remove_plugins=self.remove_mods)
|
||||||
self.__dict__[name] = x
|
self.__dict__[name] = x
|
||||||
return x
|
return x
|
||||||
|
@ -431,7 +434,7 @@ class FSCollector(Collector):
|
||||||
|
|
||||||
self._norecursepatterns = self.config.getini("norecursedirs")
|
self._norecursepatterns = self.config.getini("norecursedirs")
|
||||||
|
|
||||||
def _gethookproxy(self, fspath):
|
def _gethookproxy(self, fspath: py.path.local):
|
||||||
# check if we have the common case of running
|
# check if we have the common case of running
|
||||||
# hooks with all conftest.py files
|
# hooks with all conftest.py files
|
||||||
pm = self.config.pluginmanager
|
pm = self.config.pluginmanager
|
||||||
|
|
|
@ -578,7 +578,7 @@ class Package(Module):
|
||||||
func = partial(_call_with_optional_argument, teardown_module, self.obj)
|
func = partial(_call_with_optional_argument, teardown_module, self.obj)
|
||||||
self.addfinalizer(func)
|
self.addfinalizer(func)
|
||||||
|
|
||||||
def gethookproxy(self, fspath):
|
def gethookproxy(self, fspath: py.path.local):
|
||||||
return super()._gethookproxy(fspath)
|
return super()._gethookproxy(fspath)
|
||||||
|
|
||||||
def _collectfile(self, path, handle_dupes=True):
|
def _collectfile(self, path, handle_dupes=True):
|
||||||
|
|
Loading…
Reference in New Issue