parent
9950fdc3eb
commit
6843c64a95
|
@ -80,12 +80,12 @@ class FuncargRequest:
|
||||||
self._pyfuncitem = pyfuncitem
|
self._pyfuncitem = pyfuncitem
|
||||||
self.argname = argname
|
self.argname = argname
|
||||||
self.function = pyfuncitem.obj
|
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.cls = getattr(self.function, 'im_class', None)
|
||||||
self.config = pyfuncitem.config
|
self.config = pyfuncitem.config
|
||||||
self.fspath = pyfuncitem.fspath
|
self.fspath = pyfuncitem.fspath
|
||||||
self._plugins = self.config.pluginmanager.getplugins()
|
self._plugins = self.config.pluginmanager.getplugins()
|
||||||
self._plugins.append(pyfuncitem.getmodulecollector().obj)
|
self._plugins.append(self.module)
|
||||||
self._provider = self.config.pluginmanager.listattr(
|
self._provider = self.config.pluginmanager.listattr(
|
||||||
plugins=self._plugins,
|
plugins=self._plugins,
|
||||||
attrname=self._argprefix + str(argname)
|
attrname=self._argprefix + str(argname)
|
||||||
|
|
|
@ -38,10 +38,6 @@ class PyobjMixin(object):
|
||||||
def _getobj(self):
|
def _getobj(self):
|
||||||
return getattr(self.parent.obj, self.name)
|
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):
|
def _getparent(self, cls):
|
||||||
current = self
|
current = self
|
||||||
while current and not isinstance(current, cls):
|
while current and not isinstance(current, cls):
|
||||||
|
@ -167,10 +163,10 @@ class PyCollectorMixin(PyobjMixin, py.test.collect.Collector):
|
||||||
return self._genfunctions(name, obj)
|
return self._genfunctions(name, obj)
|
||||||
|
|
||||||
def _genfunctions(self, name, funcobj):
|
def _genfunctions(self, name, funcobj):
|
||||||
module = self.getmodulecollector().obj
|
module = self._getparent(Module).obj
|
||||||
# due to _buildname2items funcobj is the raw function, we need
|
# due to _buildname2items funcobj is the raw function, we need
|
||||||
# to work to get at the class
|
# to work to get at the class
|
||||||
clscol = self.getclasscollector()
|
clscol = self._getparent(Class)
|
||||||
cls = clscol and clscol.obj or None
|
cls = clscol and clscol.obj or None
|
||||||
funcspec = funcargs.FuncSpecs(funcobj, config=self.config, cls=cls, module=module)
|
funcspec = funcargs.FuncSpecs(funcobj, config=self.config, cls=cls, module=module)
|
||||||
gentesthook = self.config.hook.pytest_genfunc.clone(extralookup=module)
|
gentesthook = self.config.hook.pytest_genfunc.clone(extralookup=module)
|
||||||
|
|
Loading…
Reference in New Issue