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:
@@ -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__', {})]
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user