introduce an option that avoids discovery of classes other than unittest.TestCase in modules

importing unittest.
This commit is contained in:
holger krekel
2010-11-06 23:45:48 +01:00
parent 707775dcfa
commit d0ac4135a2
7 changed files with 46 additions and 15 deletions

View File

@@ -59,6 +59,8 @@ def pytest_pycollect_makeitem(__multicall__, collector, name, obj):
if res is not None:
return res
if collector._istestclasscandidate(name, obj):
if hasattr(collector.obj, 'unittest'):
return # we assume it's a mixin class for a TestCase derived one
return Class(name, parent=collector)
elif collector.funcnamefilter(name) and hasattr(obj, '__call__'):
if is_generator(obj):
@@ -124,6 +126,7 @@ class PyobjMixin(object):
return self._fslineno
def reportinfo(self):
# XXX caching?
obj = self.obj
if hasattr(obj, 'compat_co_firstlineno'):
# nose compatibility