parent
1e84a3c451
commit
4a70a667bb
|
@ -49,9 +49,9 @@ class PluginHooks:
|
||||||
def pytest_collect_directory(self, path, parent):
|
def pytest_collect_directory(self, path, parent):
|
||||||
""" return Collection node or None. """
|
""" return Collection node or None. """
|
||||||
|
|
||||||
def pytest_pymodule_makeitem(self, modcol, name, obj):
|
def pytest_pycollect_obj(self, collector, name, obj):
|
||||||
""" return custom item/collector for a python object in a module, or None. """
|
""" return custom item/collector for a python object in a module, or None. """
|
||||||
pytest_pymodule_makeitem.firstresult = True
|
pytest_pycollect_obj.firstresult = True
|
||||||
|
|
||||||
def pytest_collectstart(self, collector):
|
def pytest_collectstart(self, collector):
|
||||||
""" collector starts collecting. """
|
""" collector starts collecting. """
|
||||||
|
|
|
@ -18,9 +18,9 @@ import py
|
||||||
class UnittestPlugin:
|
class UnittestPlugin:
|
||||||
""" discover and integrate traditional ``unittest.py`` tests.
|
""" discover and integrate traditional ``unittest.py`` tests.
|
||||||
"""
|
"""
|
||||||
def pytest_pymodule_makeitem(self, modcol, name, obj):
|
def pytest_pycollect_obj(self, collector, name, obj):
|
||||||
if py.std.inspect.isclass(obj) and issubclass(obj, py.std.unittest.TestCase):
|
if py.std.inspect.isclass(obj) and issubclass(obj, py.std.unittest.TestCase):
|
||||||
return UnitTestCase(name, parent=modcol)
|
return UnitTestCase(name, parent=collector)
|
||||||
|
|
||||||
class UnitTestCase(py.test.collect.Class):
|
class UnitTestCase(py.test.collect.Class):
|
||||||
def collect(self):
|
def collect(self):
|
||||||
|
|
|
@ -135,8 +135,8 @@ class PyCollectorMixin(PyobjMixin, py.test.collect.Collector):
|
||||||
return self.join(name)
|
return self.join(name)
|
||||||
|
|
||||||
def makeitem(self, name, obj):
|
def makeitem(self, name, obj):
|
||||||
res = self.config.hook.pytest_pymodule_makeitem(
|
res = self.config.hook.pytest_pycollect_obj(
|
||||||
modcol=self, name=name, obj=obj)
|
collector=self, name=name, obj=obj)
|
||||||
if res:
|
if res:
|
||||||
return res
|
return res
|
||||||
if (self.classnamefilter(name)) and \
|
if (self.classnamefilter(name)) and \
|
||||||
|
|
Loading…
Reference in New Issue