[svn r63593] have plugin method run the test item and report about it
--HG-- branch : trunk
This commit is contained in:
parent
db60fe7f37
commit
f14b0c90d9
|
@ -7,9 +7,10 @@ import py
|
|||
XSpec = py.execnet.XSpec
|
||||
|
||||
def run(item, node):
|
||||
report = item.config.pytestplugins.do_itemrun(item)
|
||||
report.node = node
|
||||
return report
|
||||
from py.__.test.runner import basic_run_report
|
||||
rep = basic_run_report(item)
|
||||
rep.node = node
|
||||
return rep
|
||||
|
||||
class MockNode:
|
||||
def __init__(self):
|
||||
|
|
|
@ -28,6 +28,8 @@ class EventQueue:
|
|||
if name == eventname:
|
||||
return args
|
||||
events.append(name)
|
||||
if name == "internalerror":
|
||||
print str(kwargs["excrepr"])
|
||||
|
||||
class MySetup:
|
||||
def __init__(self, pyfuncitem):
|
||||
|
|
|
@ -106,12 +106,16 @@ class SlaveNode(object):
|
|||
def sendevent(self, eventname, *args, **kwargs):
|
||||
self.channel.send((eventname, args, kwargs))
|
||||
|
||||
def pyevent__itemtestreport(self, report):
|
||||
self.sendevent("itemtestreport", report)
|
||||
|
||||
def run(self):
|
||||
channel = self.channel
|
||||
self.config, basetemp = channel.receive()
|
||||
if basetemp:
|
||||
self.config.basetemp = py.path.local(basetemp)
|
||||
self.config.pytestplugins.do_configure(self.config)
|
||||
self.config.pytestplugins.register(self)
|
||||
self.sendevent("slaveready")
|
||||
try:
|
||||
while 1:
|
||||
|
@ -121,16 +125,12 @@ class SlaveNode(object):
|
|||
break
|
||||
if isinstance(task, list):
|
||||
for item in task:
|
||||
self.runtest(item)
|
||||
item.config.pytestplugins.do_itemrun(item)
|
||||
else:
|
||||
self.runtest(task)
|
||||
task.config.pytestplugins.do_itemrun(item=task)
|
||||
except KeyboardInterrupt:
|
||||
raise
|
||||
except:
|
||||
er = py.code.ExceptionInfo().getrepr(funcargs=True, showlocals=True)
|
||||
self.sendevent("internalerror", excrepr=er)
|
||||
raise
|
||||
|
||||
def runtest(self, item):
|
||||
report = item.config.pytestplugins.do_itemrun(item)
|
||||
self.sendevent("itemtestreport", report)
|
||||
|
|
|
@ -10,7 +10,8 @@ class DefaultPlugin:
|
|||
else:
|
||||
runner = basic_run_report
|
||||
report = runner(item, pdb=pdb)
|
||||
return report
|
||||
item.config.pytestplugins.notify("itemtestreport", report)
|
||||
return True
|
||||
|
||||
def pytest_pyfunc_call(self, pyfuncitem, args, kwargs):
|
||||
pyfuncitem.obj(*args, **kwargs)
|
||||
|
|
|
@ -106,7 +106,9 @@ class PytestPlugins(object):
|
|||
config.bus.unregister(self)
|
||||
|
||||
def do_itemrun(self, item, pdb=None):
|
||||
return self.pyplugins.call_firstresult("pytest_itemrun", item=item, pdb=pdb)
|
||||
res = self.pyplugins.call_firstresult("pytest_itemrun", item=item, pdb=pdb)
|
||||
if res is None:
|
||||
raise ValueError("could not run %r" %(item,))
|
||||
|
||||
#
|
||||
# XXX old code to automatically load classes
|
||||
|
|
|
@ -105,7 +105,6 @@ class Session(object):
|
|||
colitems = self.getinitialitems(colitems)
|
||||
self.shouldstop = False
|
||||
self.sessionstarts()
|
||||
#self.bus.notify("testnodeready", maketestnodeready())
|
||||
exitstatus = outcome.EXIT_OK
|
||||
captured_excinfo = None
|
||||
try:
|
||||
|
@ -134,5 +133,4 @@ class Session(object):
|
|||
|
||||
def runtest(self, item):
|
||||
pdb = self.config.option.usepdb and self.runpdb or None
|
||||
report = item.config.pytestplugins.do_itemrun(item, pdb=pdb)
|
||||
self.bus.notify("itemtestreport", report)
|
||||
item.config.pytestplugins.do_itemrun(item, pdb=pdb)
|
||||
|
|
Loading…
Reference in New Issue