allow unittest test functions to work with the "pytestmark" mechanism

by refactoring mark/keyword handling and initialization

--HG--
branch : trunk
This commit is contained in:
holger krekel
2010-10-25 23:08:56 +02:00
parent a6f10a6d80
commit 4480401119
11 changed files with 90 additions and 88 deletions

View File

@@ -136,6 +136,7 @@ class PyCollectorMixin(PyobjMixin, pytest.collect.Collector):
def collect(self):
# 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__', {})]
for basecls in inspect.getmro(self.obj.__class__):
dicts.append(basecls.__dict__)
@@ -254,9 +255,6 @@ class Instance(PyCollectorMixin, pytest.collect.Collector):
def _getobj(self):
return self.parent.obj()
def _keywords(self):
return []
def newinstance(self):
self.obj = self._getobj()
return self.obj
@@ -449,6 +447,7 @@ def hasinit(obj):
def getfuncargnames(function):
# XXX merge with _core.py's varnames
argnames = py.std.inspect.getargs(py.code.getrawcode(function))[0]
startindex = py.std.inspect.ismethod(function) and 1 or 0
defaults = getattr(function, 'func_defaults',