main: couple of code simplifications

This commit is contained in:
Ran Benita 2020-08-24 11:14:57 +03:00
parent 023f0510af
commit c1f975668e
2 changed files with 10 additions and 13 deletions

View File

@ -511,9 +511,8 @@ class Session(nodes.FSCollector):
if ihook.pytest_ignore_collect(path=path, config=self.config): if ihook.pytest_ignore_collect(path=path, config=self.config):
return False return False
norecursepatterns = self.config.getini("norecursedirs") norecursepatterns = self.config.getini("norecursedirs")
for pat in norecursepatterns: if any(path.check(fnmatch=pat) for pat in norecursepatterns):
if path.check(fnmatch=pat): return False
return False
return True return True
def _collectfile( def _collectfile(
@ -650,13 +649,12 @@ class Session(nodes.FSCollector):
if parent.isdir(): if parent.isdir():
pkginit = parent.join("__init__.py") pkginit = parent.join("__init__.py")
if pkginit.isfile(): if pkginit.isfile() and pkginit not in node_cache1:
if pkginit not in node_cache1: col = self._collectfile(pkginit, handle_dupes=False)
col = self._collectfile(pkginit, handle_dupes=False) if col:
if col: if isinstance(col[0], Package):
if isinstance(col[0], Package): pkg_roots[str(parent)] = col[0]
pkg_roots[str(parent)] = col[0] node_cache1[col[0].fspath] = [col[0]]
node_cache1[col[0].fspath] = [col[0]]
# If it's a directory argument, recurse and look for any Subpackages. # If it's a directory argument, recurse and look for any Subpackages.
# Let the Package collector deal with subnodes, don't collect here. # Let the Package collector deal with subnodes, don't collect here.

View File

@ -644,9 +644,8 @@ class Package(Module):
if ihook.pytest_ignore_collect(path=path, config=self.config): if ihook.pytest_ignore_collect(path=path, config=self.config):
return False return False
norecursepatterns = self.config.getini("norecursedirs") norecursepatterns = self.config.getini("norecursedirs")
for pat in norecursepatterns: if any(path.check(fnmatch=pat) for pat in norecursepatterns):
if path.check(fnmatch=pat): return False
return False
return True return True
def _collectfile( def _collectfile(