Merge pull request #4250 from blueyed/ignore-pyc
collection: _recurse: skip __pycache__
This commit is contained in:
commit
233c2a23de
|
@ -517,8 +517,19 @@ class Session(nodes.FSCollector):
|
||||||
# Let the Package collector deal with subnodes, don't collect here.
|
# Let the Package collector deal with subnodes, don't collect here.
|
||||||
if argpath.check(dir=1):
|
if argpath.check(dir=1):
|
||||||
assert not names, "invalid arg %r" % (arg,)
|
assert not names, "invalid arg %r" % (arg,)
|
||||||
|
|
||||||
|
if six.PY2:
|
||||||
|
|
||||||
|
def filter_(f):
|
||||||
|
return f.check(file=1) and not f.strpath.endswith("*.pyc")
|
||||||
|
|
||||||
|
else:
|
||||||
|
|
||||||
|
def filter_(f):
|
||||||
|
return f.check(file=1)
|
||||||
|
|
||||||
for path in argpath.visit(
|
for path in argpath.visit(
|
||||||
fil=lambda x: x.check(file=1), rec=self._recurse, bf=True, sort=True
|
fil=filter_, rec=self._recurse, bf=True, sort=True
|
||||||
):
|
):
|
||||||
pkginit = path.dirpath().join("__init__.py")
|
pkginit = path.dirpath().join("__init__.py")
|
||||||
if pkginit.exists() and not any(x in pkginit.parts() for x in paths):
|
if pkginit.exists() and not any(x in pkginit.parts() for x in paths):
|
||||||
|
@ -562,15 +573,17 @@ class Session(nodes.FSCollector):
|
||||||
|
|
||||||
return ihook.pytest_collect_file(path=path, parent=self)
|
return ihook.pytest_collect_file(path=path, parent=self)
|
||||||
|
|
||||||
def _recurse(self, path):
|
def _recurse(self, dirpath):
|
||||||
ihook = self.gethookproxy(path.dirpath())
|
if dirpath.basename == "__pycache__":
|
||||||
if ihook.pytest_ignore_collect(path=path, config=self.config):
|
return False
|
||||||
return
|
ihook = self.gethookproxy(dirpath.dirpath())
|
||||||
|
if ihook.pytest_ignore_collect(path=dirpath, config=self.config):
|
||||||
|
return False
|
||||||
for pat in self._norecursepatterns:
|
for pat in self._norecursepatterns:
|
||||||
if path.check(fnmatch=pat):
|
if dirpath.check(fnmatch=pat):
|
||||||
return False
|
return False
|
||||||
ihook = self.gethookproxy(path)
|
ihook = self.gethookproxy(dirpath)
|
||||||
ihook.pytest_collect_directory(path=path, parent=self)
|
ihook.pytest_collect_directory(path=dirpath, parent=self)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _tryconvertpyarg(self, x):
|
def _tryconvertpyarg(self, x):
|
||||||
|
|
|
@ -516,15 +516,17 @@ class Package(Module):
|
||||||
self._norecursepatterns = session._norecursepatterns
|
self._norecursepatterns = session._norecursepatterns
|
||||||
self.fspath = fspath
|
self.fspath = fspath
|
||||||
|
|
||||||
def _recurse(self, path):
|
def _recurse(self, dirpath):
|
||||||
ihook = self.gethookproxy(path.dirpath())
|
if dirpath.basename == "__pycache__":
|
||||||
if ihook.pytest_ignore_collect(path=path, config=self.config):
|
|
||||||
return False
|
return False
|
||||||
|
ihook = self.gethookproxy(dirpath.dirpath())
|
||||||
|
if ihook.pytest_ignore_collect(path=dirpath, config=self.config):
|
||||||
|
return
|
||||||
for pat in self._norecursepatterns:
|
for pat in self._norecursepatterns:
|
||||||
if path.check(fnmatch=pat):
|
if dirpath.check(fnmatch=pat):
|
||||||
return False
|
return False
|
||||||
ihook = self.gethookproxy(path)
|
ihook = self.gethookproxy(dirpath)
|
||||||
ihook.pytest_collect_directory(path=path, parent=self)
|
ihook.pytest_collect_directory(path=dirpath, parent=self)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def gethookproxy(self, fspath):
|
def gethookproxy(self, fspath):
|
||||||
|
|
Loading…
Reference in New Issue