factor out session main loop so that distribute testing can make use of it
--HG-- branch : trunk
This commit is contained in:
parent
7629b8fda7
commit
7084313408
|
@ -97,22 +97,26 @@ class Session(object):
|
||||||
self.shouldstop = False
|
self.shouldstop = False
|
||||||
self.sessionstarts()
|
self.sessionstarts()
|
||||||
exitstatus = outcome.EXIT_OK
|
exitstatus = outcome.EXIT_OK
|
||||||
captured_excinfo = None
|
|
||||||
try:
|
try:
|
||||||
for item in self.collect(colitems):
|
self._mainloop(colitems)
|
||||||
if self.shouldstop:
|
if self._testsfailed:
|
||||||
break
|
exitstatus = outcome.EXIT_TESTSFAILED
|
||||||
if not self.config.option.collectonly:
|
self.sessionfinishes(exitstatus=exitstatus)
|
||||||
item.config.hook.pytest_runtest_protocol(item=item)
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
excinfo = py.code.ExceptionInfo()
|
excinfo = py.code.ExceptionInfo()
|
||||||
self.config.hook.pytest_keyboard_interrupt(excinfo=excinfo)
|
self.config.hook.pytest_keyboard_interrupt(excinfo=excinfo)
|
||||||
exitstatus = outcome.EXIT_INTERRUPTED
|
exitstatus = outcome.EXIT_INTERRUPTED
|
||||||
except:
|
except:
|
||||||
excinfo = py.code.ExceptionInfo()
|
excinfo = py.code.ExceptionInfo()
|
||||||
self.config.pluginmanager.notify_exception(captured_excinfo)
|
self.config.pluginmanager.notify_exception(excinfo)
|
||||||
exitstatus = outcome.EXIT_INTERNALERROR
|
exitstatus = outcome.EXIT_INTERNALERROR
|
||||||
if exitstatus == 0 and self._testsfailed:
|
if exitstatus in (outcome.EXIT_INTERNALERROR, outcome.EXIT_INTERRUPTED):
|
||||||
exitstatus = outcome.EXIT_TESTSFAILED
|
|
||||||
self.sessionfinishes(exitstatus=exitstatus)
|
self.sessionfinishes(exitstatus=exitstatus)
|
||||||
return exitstatus
|
return exitstatus
|
||||||
|
|
||||||
|
def _mainloop(self, colitems):
|
||||||
|
for item in self.collect(colitems):
|
||||||
|
if self.shouldstop:
|
||||||
|
break
|
||||||
|
if not self.config.option.collectonly:
|
||||||
|
item.config.hook.pytest_runtest_protocol(item=item)
|
||||||
|
|
Loading…
Reference in New Issue