[svn r63588] shift running of test item to be done through a plugin method.
--HG-- branch : trunk
This commit is contained in:
parent
79793d50e2
commit
db60fe7f37
|
@ -465,14 +465,8 @@ class Directory(FSCollector):
|
|||
return self.config.pytestplugins.call_each(
|
||||
'pytest_collect_directory', path=path, parent=self)
|
||||
|
||||
from py.__.test.runner import basic_run_report, forked_run_report
|
||||
class Item(Node):
|
||||
""" a basic test item. """
|
||||
def _getrunner(self):
|
||||
if self.config.option.boxed:
|
||||
return forked_run_report
|
||||
return basic_run_report
|
||||
|
||||
def _deprecated_testexecution(self):
|
||||
if self.__class__.run != Item.run:
|
||||
warnoldtestrun()
|
||||
|
|
|
@ -7,10 +7,9 @@ import py
|
|||
XSpec = py.execnet.XSpec
|
||||
|
||||
def run(item, node):
|
||||
runner = item._getrunner()
|
||||
rep = runner(item)
|
||||
rep.node = node
|
||||
return rep
|
||||
report = item.config.pytestplugins.do_itemrun(item)
|
||||
report.node = node
|
||||
return report
|
||||
|
||||
class MockNode:
|
||||
def __init__(self):
|
||||
|
|
|
@ -132,7 +132,5 @@ class SlaveNode(object):
|
|||
raise
|
||||
|
||||
def runtest(self, item):
|
||||
runner = item._getrunner()
|
||||
testrep = runner(item)
|
||||
self.sendevent("itemtestreport", testrep)
|
||||
|
||||
report = item.config.pytestplugins.do_itemrun(item)
|
||||
self.sendevent("itemtestreport", report)
|
||||
|
|
|
@ -36,6 +36,9 @@ class PluginHooks:
|
|||
def pytest_pymodule_makeitem(self, modcol, name, obj):
|
||||
""" return custom item/collector for a python object in a module, or None. """
|
||||
|
||||
def pytest_itemrun(self, item, pdb=None):
|
||||
""" run given test item and return test report. """
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# runtest related hooks
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
|
@ -3,6 +3,15 @@ import py
|
|||
class DefaultPlugin:
|
||||
""" Plugin implementing defaults and general options. """
|
||||
|
||||
def pytest_itemrun(self, item, pdb=None):
|
||||
from py.__.test.runner import basic_run_report, forked_run_report
|
||||
if item.config.option.boxed:
|
||||
runner = forked_run_report
|
||||
else:
|
||||
runner = basic_run_report
|
||||
report = runner(item, pdb=pdb)
|
||||
return report
|
||||
|
||||
def pytest_pyfunc_call(self, pyfuncitem, args, kwargs):
|
||||
pyfuncitem.obj(*args, **kwargs)
|
||||
|
||||
|
@ -13,8 +22,8 @@ class DefaultPlugin:
|
|||
path in parent.config.args:
|
||||
if ext == ".py":
|
||||
return parent.Module(path, parent=parent)
|
||||
|
||||
def pytest_collect_directory(self, path, parent):
|
||||
|
||||
def pytest_collect_recurse(self, path, parent):
|
||||
#excludelist = parent._config.getvalue_pathlist('dir_exclude', path)
|
||||
#if excludelist and path in excludelist:
|
||||
# return
|
||||
|
@ -24,7 +33,11 @@ class DefaultPlugin:
|
|||
if path == arg or arg.relto(path):
|
||||
break
|
||||
else:
|
||||
return
|
||||
return False
|
||||
return True
|
||||
|
||||
def pytest_collect_directory(self, path, parent):
|
||||
# XXX reconsider the following comment
|
||||
# not use parent.Directory here as we generally
|
||||
# want dir/conftest.py to be able to
|
||||
# define Directory(dir) already
|
||||
|
|
|
@ -105,6 +105,9 @@ class PytestPlugins(object):
|
|||
self.pyplugins.call_each("pytest_unconfigure", config=config)
|
||||
config.bus.unregister(self)
|
||||
|
||||
def do_itemrun(self, item, pdb=None):
|
||||
return self.pyplugins.call_firstresult("pytest_itemrun", item=item, pdb=pdb)
|
||||
|
||||
#
|
||||
# XXX old code to automatically load classes
|
||||
#
|
||||
|
|
|
@ -133,7 +133,6 @@ class Session(object):
|
|||
post_mortem(excinfo._excinfo[2])
|
||||
|
||||
def runtest(self, item):
|
||||
runner = item._getrunner()
|
||||
pdb = self.config.option.usepdb and self.runpdb or None
|
||||
testrep = runner(item, pdb=pdb)
|
||||
self.bus.notify("itemtestreport", testrep)
|
||||
report = item.config.pytestplugins.do_itemrun(item, pdb=pdb)
|
||||
self.bus.notify("itemtestreport", report)
|
||||
|
|
Loading…
Reference in New Issue