Merge pull request #1206 from The-Compiler/collect-getattr

Don't collect classes with truthy __getattr__.
This commit is contained in:
Ronny Pfannschmidt
2015-11-30 17:23:47 +01:00
2 changed files with 33 additions and 1 deletions

View File

@@ -406,7 +406,10 @@ class PyCollector(PyobjMixin, pytest.Collector):
""" Look for the __test__ attribute, which is applied by the
@nose.tools.istest decorator
"""
return safe_getattr(obj, '__test__', False)
# We explicitly check for "is True" here to not mistakenly treat
# classes with a custom __getattr__ returning something truthy (like a
# function) as test classes.
return safe_getattr(obj, '__test__', False) is True
def classnamefilter(self, name):
return self._matches_prefix_or_glob_option('python_classes', name)