main: move norecursedir check to main's pytest_ignore_collect
Fix #11081
This commit is contained in:
parent
85c5bd26b6
commit
ae38b076da
|
@ -0,0 +1 @@
|
||||||
|
The :confval:`norecursedir` check is now performed in a :hook:`pytest_ignore_collect` implementation, so plugins can affect it.
|
|
@ -400,6 +400,12 @@ def pytest_ignore_collect(collection_path: Path, config: Config) -> Optional[boo
|
||||||
allow_in_venv = config.getoption("collect_in_virtualenv")
|
allow_in_venv = config.getoption("collect_in_virtualenv")
|
||||||
if not allow_in_venv and _in_venv(collection_path):
|
if not allow_in_venv and _in_venv(collection_path):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
if collection_path.is_dir():
|
||||||
|
norecursepatterns = config.getini("norecursedirs")
|
||||||
|
if any(fnmatch_ex(pat, collection_path) for pat in norecursepatterns):
|
||||||
|
return True
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
@ -563,9 +569,6 @@ class Session(nodes.FSCollector):
|
||||||
ihook = self.gethookproxy(fspath.parent)
|
ihook = self.gethookproxy(fspath.parent)
|
||||||
if ihook.pytest_ignore_collect(collection_path=fspath, config=self.config):
|
if ihook.pytest_ignore_collect(collection_path=fspath, config=self.config):
|
||||||
return False
|
return False
|
||||||
norecursepatterns = self.config.getini("norecursedirs")
|
|
||||||
if any(fnmatch_ex(pat, fspath) for pat in norecursepatterns):
|
|
||||||
return False
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _collectfile(
|
def _collectfile(
|
||||||
|
|
|
@ -706,9 +706,6 @@ class Package(Module):
|
||||||
ihook = self.session.gethookproxy(fspath.parent)
|
ihook = self.session.gethookproxy(fspath.parent)
|
||||||
if ihook.pytest_ignore_collect(collection_path=fspath, config=self.config):
|
if ihook.pytest_ignore_collect(collection_path=fspath, config=self.config):
|
||||||
return False
|
return False
|
||||||
norecursepatterns = self.config.getini("norecursedirs")
|
|
||||||
if any(fnmatch_ex(pat, fspath) for pat in norecursepatterns):
|
|
||||||
return False
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _collectfile(
|
def _collectfile(
|
||||||
|
|
Loading…
Reference in New Issue