diff --git a/py/test/funcargs.py b/py/test/funcargs.py index 7ebdcd331..016f764e9 100644 --- a/py/test/funcargs.py +++ b/py/test/funcargs.py @@ -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) diff --git a/py/test/pycollect.py b/py/test/pycollect.py index 4c60a4a9b..ab2740c8a 100644 --- a/py/test/pycollect.py +++ b/py/test/pycollect.py @@ -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)