[py-svn] r48140 - in py/branch/reporter-merge/py/test: . testing
fijal at codespeak.net
fijal at codespeak.net
Sun Oct 28 19:43:21 CET 2007
Author: fijal
Date: Sun Oct 28 19:43:21 2007
New Revision: 48140
Modified:
py/branch/reporter-merge/py/test/defaultconftest.py
py/branch/reporter-merge/py/test/executor.py
py/branch/reporter-merge/py/test/session.py
py/branch/reporter-merge/py/test/testing/test_session.py
py/branch/reporter-merge/py/test/testing/test_session2.py
Log:
Reintroduce boxing
Modified: py/branch/reporter-merge/py/test/defaultconftest.py
==============================================================================
--- py/branch/reporter-merge/py/test/defaultconftest.py (original)
+++ py/branch/reporter-merge/py/test/defaultconftest.py Sun Oct 28 19:43:21 2007
@@ -88,9 +88,9 @@
action="store_true", dest="runbrowser", default=False,
help="run browser (implies --startserver)."
),
- #Option('', '--boxed',
- # action="store_true", dest="boxed", default=False,
- # help="box each test run in a separate process"),
+ Option('', '--boxed',
+ action="store_true", dest="boxed", default=False,
+ help="box each test run in a separate process"),
Option('', '--rest',
action='store_true', dest="restreport", default=False,
help="restructured text output reporting."),
Modified: py/branch/reporter-merge/py/test/executor.py
==============================================================================
--- py/branch/reporter-merge/py/test/executor.py (original)
+++ py/branch/reporter-merge/py/test/executor.py Sun Oct 28 19:43:21 2007
@@ -105,7 +105,7 @@
return (passed, setupfailure, excinfo, skipped, critical, 0,
b.stdoutrepr, b.stderrrepr)
else:
- return (False, False, None, False, False, b.signal,
+ return (False, False, None, None, False, b.signal,
b.stdoutrepr, b.stderrrepr)
class AsyncExecutor(RunExecutor):
Modified: py/branch/reporter-merge/py/test/session.py
==============================================================================
--- py/branch/reporter-merge/py/test/session.py (original)
+++ py/branch/reporter-merge/py/test/session.py Sun Oct 28 19:43:21 2007
@@ -5,7 +5,7 @@
from py.__.test import repevent
from py.__.test.outcome import SerializableOutcome, ReprOutcome
from py.__.test.reporter import LocalReporter
-from py.__.test.executor import RunExecutor
+from py.__.test.executor import RunExecutor, BoxExecutor
""" The session implementation - reporter version:
@@ -144,9 +144,14 @@
self.footer(colitems)
def run(self, item):
- executor = RunExecutor(item, self.config.option.usepdb, self.reporter,
- self.config)
- return ReprOutcome(executor.execute().make_repr())
+ if not self.config.option.boxed:
+ executor = RunExecutor(item, self.config.option.usepdb,
+ self.reporter, self.config)
+ return ReprOutcome(executor.execute().make_repr())
+ else:
+ executor = BoxExecutor(item, self.config.option.usepdb,
+ self.reporter, self.config)
+ return ReprOutcome(executor.execute())
class Exit(Exception):
""" for immediate program exits without tracebacks and reporter/summary. """
Modified: py/branch/reporter-merge/py/test/testing/test_session.py
==============================================================================
--- py/branch/reporter-merge/py/test/testing/test_session.py (original)
+++ py/branch/reporter-merge/py/test/testing/test_session.py Sun Oct 28 19:43:21 2007
@@ -158,25 +158,6 @@
assert len(getfailed(all)) == 1
assert not getpassed(all)
- def test_recursion_detection(self):
- py.test.skip("XXX the test is bogus here")
- o = tmpdir.ensure('recursiontest', dir=1)
- tfile = o.join('test_recursion.py')
- tfile.write(py.code.Source("""
- def test_1():
- def f():
- g()
- def g():
- f()
- f()
- """))
- session, all = self.mainsession(o)
- print "back from main", o
- #print out
- outcomes = getoutcomes(all)
- i = out.find('Recursion detected')
- assert i != -1
-
def test_generator_yields_None(self):
o = tmpdir.ensure('generatornonetest', dir=1)
tfile = o.join('test_generatornone.py')
Modified: py/branch/reporter-merge/py/test/testing/test_session2.py
==============================================================================
--- py/branch/reporter-merge/py/test/testing/test_session2.py (original)
+++ py/branch/reporter-merge/py/test/testing/test_session2.py Sun Oct 28 19:43:21 2007
@@ -14,7 +14,7 @@
class TestSession(object):
# XXX: Some tests of that should be run as well on RSession, while
# some not at all
- def example_distribution(self):
+ def example_distribution(self, boxed=False):
# XXX find a better way for the below
tmpdir = tmp
dirname = "sub_lsession"#+runner.func_name
@@ -33,6 +33,8 @@
# os.kill(os.getpid(), 11)
"""))
args = [str(tmpdir.join(dirname))]
+ if boxed:
+ args.append('--boxed')
config = py.test.config._reparse(args)
lsession = Session(config)
allevents = []
@@ -62,14 +64,35 @@
assert str(tb[0].path).find("executor") != -1
assert str(tb[0].source).find("execute") != -1
- def test_normal(self):
- py.test.skip("Boxing not supported")
+ def test_boxed(self):
if not hasattr(py.std.os, 'fork'):
py.test.skip('operating system not supported')
- self.example_distribution(box_runner)
+ self.example_distribution(True)
+
+ def test_box_exploding(self):
+ if not hasattr(py.std.os, 'fork'):
+ py.test.skip('operating system not supported')
+ tmpdir = tmp
+ dirname = "boxtest"
+ tmpdir.ensure(dirname, "__init__.py")
+ tmpdir.ensure(dirname, "test_one.py").write(py.code.Source("""
+ def test_5():
+ import os
+ os.kill(os.getpid(), 11)
+ """))
+ args = [str(tmpdir.join(dirname))]
+ args.append('--boxed')
+ config = py.test.config._reparse(args)
+ lsession = Session(config)
+ allevents = []
+ lsession.main(reporter=allevents.append)
+ testevents = [x for x in allevents
+ if isinstance(x, repevent.ReceivedItemOutcome)]
+ assert len(testevents)
+ assert testevents[0].outcome.signal
def test_plain(self):
- self.example_distribution()
+ self.example_distribution(False)
def test_pdb_run(self):
# we make sure that pdb is engaged
More information about the pytest-commit
mailing list