avoid superflous methods

--HG--
branch : trunk
This commit is contained in:
holger krekel 2009-05-12 11:29:14 +02:00
parent 9950fdc3eb
commit 6843c64a95
2 changed files with 4 additions and 8 deletions

View File

@ -80,12 +80,12 @@ class FuncargRequest:
self._pyfuncitem = pyfuncitem
self.argname = argname
self.function = pyfuncitem.obj
self.module = pyfuncitem.getmodulecollector().obj
self.module = pyfuncitem._getparent(py.test.collect.Module).obj
self.cls = getattr(self.function, 'im_class', None)
self.config = pyfuncitem.config
self.fspath = pyfuncitem.fspath
self._plugins = self.config.pluginmanager.getplugins()
self._plugins.append(pyfuncitem.getmodulecollector().obj)
self._plugins.append(self.module)
self._provider = self.config.pluginmanager.listattr(
plugins=self._plugins,
attrname=self._argprefix + str(argname)

View File

@ -38,10 +38,6 @@ class PyobjMixin(object):
def _getobj(self):
return getattr(self.parent.obj, self.name)
def getmodulecollector(self):
return self._getparent(Module)
def getclasscollector(self):
return self._getparent(Class)
def _getparent(self, cls):
current = self
while current and not isinstance(current, cls):
@ -167,10 +163,10 @@ class PyCollectorMixin(PyobjMixin, py.test.collect.Collector):
return self._genfunctions(name, obj)
def _genfunctions(self, name, funcobj):
module = self.getmodulecollector().obj
module = self._getparent(Module).obj
# due to _buildname2items funcobj is the raw function, we need
# to work to get at the class
clscol = self.getclasscollector()
clscol = self._getparent(Class)
cls = clscol and clscol.obj or None
funcspec = funcargs.FuncSpecs(funcobj, config=self.config, cls=cls, module=module)
gentesthook = self.config.hook.pytest_genfunc.clone(extralookup=module)