def test_boxing_huge_data(): b = Box(example2.boxhuge, config=config) b.run() assert b.stdoutrepr assert b.exitstat == 0 assert b.signal == 0 assert b.retval == 3
def test_boxing_signal(): b = Box(example2.boxseg, config=config) b.run() assert b.retval is None if py.std.sys.version_info < (2,4): py.test.skip("signal detection does not work with python prior 2.4") assert b.signal == 11
def test_boxing_on_fds(): b = Box(example2.boxf2, config=config) b.run() assert b.stdoutrepr == "someout" assert b.stderrrepr == "someerr" assert b.exitstat == 0 assert b.signal == 0 assert b.retval == 2
def test_box_seq(): # we run many boxes with huge data, just one after another for i in xrange(100): b = Box(example2.boxhuge, config=config) b.run() assert b.stdoutrepr assert b.exitstat == 0 assert b.signal == 0 assert b.retval == 3
def test_basic_boxing(): # XXX: because we do not have option transfer ## if not hasattr(option, 'nocapture') or not option.nocapture: ## py.test.skip("Interacts with pylib i/o skipping which is bad actually") b = Box(example2.boxf1, config=config) b.run() assert b.stdoutrepr == "some out\n" assert b.stderrrepr == "some err\n" assert b.exitstat == 0 assert b.signal == 0 assert b.retval == 1
def test_box_in_a_box(): def boxfun(): b = Box(example2.boxf2, config=config) b.run() print b.stdoutrepr print >>sys.stderr, b.stderrrepr return b.retval b = Box(boxfun, config=config) b.run() assert b.stdoutrepr == "someout\n" assert b.stderrrepr == "someerr\n" assert b.exitstat == 0 assert b.signal == 0 assert b.retval == 2
def execute(self): def fun(): outcome = RunExecutor.execute(self, False) return outcome.make_repr(self.config.option.tbstyle) b = Box(fun, config=self.config) pid = b.run() assert pid if b.retval is not None: passed, setupfailure, excinfo, skipped, critical, _, _, _\ = b.retval return (passed, setupfailure, excinfo, skipped, critical, 0, b.stdoutrepr, b.stderrrepr) else: return (False, False, None, False, False, b.signal, b.stdoutrepr, b.stderrrepr)
def test_box_killer(): class A: pass info = A() import time def box_fun(): time.sleep(10) # we don't want to last forever here b = Box(box_fun, config=config) par, pid = b.run(continuation=True) os.kill(pid, 15) par(pid) if py.std.sys.version_info < (2,4): py.test.skip("signal detection does not work with python prior 2.4") assert b.signal == 15
def execute(self): def fun(): outcome = RunExecutor.execute(self, False) return outcome.make_repr(self.config.option.tbstyle) b = Box(fun, config=self.config) parent, pid = b.run(continuation=True) def cont(waiter=os.waitpid): parent(pid, waiter=waiter) if b.retval is not None: passed, setupfailure, excinfo, skipped,\ critical, _, _, _ = b.retval return (passed, setupfailure, excinfo, skipped, critical, 0, b.stdoutrepr, b.stderrrepr) else: return (False, False, None, False, False, b.signal, b.stdoutrepr, b.stderrrepr) return cont, pid
def boxfun(): b = Box(example2.boxf2, config=config) b.run() print b.stdoutrepr print >>sys.stderr, b.stderrrepr return b.retval