support nose-style `__test__` attribute on modules, classes and

functions, including unittest-style Classes.  If set to True, the
test will not be collected.

--HG--
branch : nose_test_attr
This commit is contained in:
holger krekel
2014-04-10 12:46:27 +02:00
parent f91049cec9
commit 494be731e3
5 changed files with 62 additions and 5 deletions

View File

@@ -314,6 +314,9 @@ class PyCollector(PyobjMixin, pytest.Collector):
return True
def collect(self):
if not getattr(self.obj, "__test__", True):
return []
# NB. we avoid random getattrs and peek in the __dict__ instead
# (XXX originally introduced from a PyPy need, still true?)
dicts = [getattr(self.obj, '__dict__', {})]

View File

@@ -41,10 +41,12 @@ class UnitTestCase(pytest.Class):
super(UnitTestCase, self).setup()
def collect(self):
cls = self.obj
if not getattr(cls, "__test__", True):
return
self.session._fixturemanager.parsefactories(self, unittest=True)
loader = py.std.unittest.TestLoader()
module = self.getparent(pytest.Module).obj
cls = self.obj
foundsomething = False
for name in loader.getTestCaseNames(self.obj):
x = getattr(self.obj, name)