New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix infinite recursion collection bug with pytest_ignore_collect hook #3771

Merged
merged 2 commits into from Aug 6, 2018
Jump to file or symbol
Failed to load files and symbols.
+7 −3
Diff settings

Always

Just for now

Viewing a subset of changes. View all
Prev

Fix recursion bug if a pytest_ignore_collect returns False instead of…

… None
  • Loading branch information...
nicoddemus committed Aug 3, 2018
commit fe0a76e1a61fab631ba21ca29a4cd13c71a3f807
@@ -0,0 +1 @@
Fix infinite recursion during collection if a ``pytest_ignore_collect`` returns ``False`` instead of ``None``.
View
@@ -561,7 +561,7 @@ def __init__(self, fspath, parent=None, config=None, session=None, nodeid=None):
def _recurse(self, path):
ihook = self.gethookproxy(path.dirpath())
if ihook.pytest_ignore_collect(path=path, config=self.config):
return
return False

This comment has been minimized.

@nicoddemus

nicoddemus Aug 3, 2018

Member

This doesn't have anything to do with the fix, just thought I would keep the return value consistent.

@nicoddemus

nicoddemus Aug 3, 2018

Member

This doesn't have anything to do with the fix, just thought I would keep the return value consistent.

for pat in self._norecursepatterns:
if path.check(fnmatch=pat):
return False
@@ -594,9 +594,12 @@ def isinitpath(self, path):
return path in self.session._initialpaths
def collect(self):
path = self.fspath.dirpath()
this_path = self.fspath.dirpath()
pkg_prefix = None
for path in path.visit(fil=lambda x: 1, rec=self._recurse, bf=True, sort=True):
for path in this_path.visit(rec=self._recurse, bf=True, sort=True):
# we will visit our own __init__.py file, in which case we skip it

This comment has been minimized.

@nicoddemus

nicoddemus Aug 3, 2018

Member

This is the actual fix. I did not understand what this had to do with pytest_ignore_collect though.

@nicoddemus

nicoddemus Aug 3, 2018

Member

This is the actual fix. I did not understand what this had to do with pytest_ignore_collect though.

This comment has been minimized.

@jonozzz

jonozzz Aug 10, 2018

visit() calls back the self._recurse(path) which in turn calls the pytest_ignore_collect

@jonozzz

jonozzz Aug 10, 2018

visit() calls back the self._recurse(path) which in turn calls the pytest_ignore_collect

if path.basename == "__init__.py" and path.dirpath() == this_path:
continue
if pkg_prefix and pkg_prefix in path.parts():
continue
for x in self._collectfile(path):
ProTip! Use n and p to navigate between commits in a pull request.