[py-svn] r56788 - in py/branch/event/py/test2: . testing
hpk at codespeak.net
hpk at codespeak.net
Fri Jul 25 17:38:09 CEST 2008
Author: hpk
Date: Fri Jul 25 17:38:09 2008
New Revision: 56788
Modified:
py/branch/event/py/test2/runner.py
py/branch/event/py/test2/testing/test_runner.py
Log:
make sure that py.test.exit() works in boxed tests
-This line, and those below, will be ignored--
M test2/runner.py
M test2/testing/test_runner.py
Modified: py/branch/event/py/test2/runner.py
==============================================================================
--- py/branch/event/py/test2/runner.py (original)
+++ py/branch/event/py/test2/runner.py Fri Jul 25 17:38:09 2008
@@ -57,19 +57,24 @@
return repevent.ItemTestReport(trail, runinfo.outcome, repr_run, repr_path)
def fork_runner(item, setupstate, getcapture):
+ EXITSTATUS_TESTEXIT = 4
+
def runforked():
- testrep = basic_runner(item, setupstate, getcapture)
+ try:
+ testrep = basic_runner(item, setupstate, getcapture)
+ except (KeyboardInterrupt, Exit):
+ os._exit(EXITSTATUS_TESTEXIT)
return testrep.dumps()
ff = py.io.ForkedFunc(runforked)
result = ff.waitfinish()
print vars(result)
-
if result.retval is not None:
return repevent.ItemTestReport.fromdumps(result.retval)
- #testrep.stdout = result.out
- #testrep.stderr = result.err
else:
+ if result.exitstatus == EXITSTATUS_TESTEXIT:
+ itemrepr = item.repr_path()
+ raise Exit("forked test item %s raised Exit" %(itemrepr,))
return report_crash(item, result)
def report_crash(item, result):
Modified: py/branch/event/py/test2/testing/test_runner.py
==============================================================================
--- py/branch/event/py/test2/testing/test_runner.py (original)
+++ py/branch/event/py/test2/testing/test_runner.py Fri Jul 25 17:38:09 2008
@@ -205,7 +205,6 @@
return runner.fork_runner
def test_exit_does_bail_out(self):
- py.test.skip("XXX needs work")
def testfunc():
raise Exit()
py.test.raises(Exit, "self.run(testfunc)")
More information about the pytest-commit
mailing list