summaryrefslogtreecommitdiff
path: root/src/_pytest/main.py
diff options
context:
space:
mode:
authorRan Benita <ran@unusedvar.com>2020-08-24 11:14:57 +0300
committerRan Benita <ran@unusedvar.com>2020-08-24 18:15:11 +0300
commitc1f975668ec94ec6e93718abd696b7eb8450360b (patch)
tree7e3bc8fe68ea9a8c5de599a52e60a78ee50259ea /src/_pytest/main.py
parent023f0510afcd2a182423b45fa79da47c275ab446 (diff)
downloadpytest-c1f975668ec94ec6e93718abd696b7eb8450360b.tar.gz
main: couple of code simplifications
Diffstat (limited to 'src/_pytest/main.py')
-rw-r--r--src/_pytest/main.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/_pytest/main.py b/src/_pytest/main.py
index c4d1ba85e..29b1e5f70 100644
--- a/src/_pytest/main.py
+++ b/src/_pytest/main.py
@@ -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.