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):
return False
norecursepatterns = self.config.getini("norecursedirs")
for pat in norecursepatterns:
if path.check(fnmatch=pat):
return False
if any(path.check(fnmatch=pat) for pat in norecursepatterns):
return False
return True
def _collectfile(
@ -650,13 +649,12 @@ class Session(nodes.FSCollector):
if parent.isdir():
pkginit = parent.join("__init__.py")
if pkginit.isfile():
if pkginit not in node_cache1:
col = self._collectfile(pkginit, handle_dupes=False)
if col:
if isinstance(col[0], Package):
pkg_roots[str(parent)] = col[0]
node_cache1[col[0].fspath] = [col[0]]
if pkginit.isfile() and pkginit not in node_cache1:
col = self._collectfile(pkginit, handle_dupes=False)
if col:
if isinstance(col[0], Package):
pkg_roots[str(parent)] = col[0]
node_cache1[col[0].fspath] = [col[0]]
# If it's a directory argument, recurse and look for any Subpackages.
# 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):
return False
norecursepatterns = self.config.getini("norecursedirs")
for pat in norecursepatterns:
if path.check(fnmatch=pat):
return False
if any(path.check(fnmatch=pat) for pat in norecursepatterns):
return False
return True
def _collectfile(