def test_exception_info_repr(): try: f3() except: outcome = Outcome(excinfo=py.code.ExceptionInfo()) repr = outcome.make_excinfo_repr("long") assert marshal.dumps(repr) excinfo = ExcInfoRepr(repr) assert str(excinfo.typename) == "ValueError" assert str(excinfo.value) == "42" assert len(excinfo.traceback) == 4 myfile = py.magic.autopath() assert excinfo.traceback[3].path == myfile assert excinfo.traceback[3].lineno == f1.func_code.co_firstlineno + 4 assert excinfo.traceback[3].relline == 5 assert excinfo.traceback[2].path == myfile assert excinfo.traceback[2].lineno == f2.func_code.co_firstlineno assert excinfo.traceback[2].relline == 1 assert excinfo.traceback[1].path == myfile assert excinfo.traceback[1].lineno == f3.func_code.co_firstlineno assert excinfo.traceback[1].relline == 1
def test_ReceivedItemOutcome_FAILED_stdout(self): excinfo = Container( typename='FooError', value='A foo has occurred', traceback=[ Container( path='foo/bar.py', lineno=1, relline=1, source='foo()', ), Container( path='foo/baz.py', lineno=4, relline=1, source='raise FooError("A foo has occurred")', ), ] ) outcome = Outcome(excinfo=excinfo) outcome.stdout = '<printed>' outcome.stderr = '' parent = Container(parent=None, fspath=py.path.local('.')) item = Container(listnames=lambda: ['', 'foo.py', 'bar', '()', 'baz'], parent=parent, fspath=py.path.local('foo')) event = repevent.ReceivedItemOutcome(channel=ch, outcome=outcome, item=item) reporter.report(event) reporter.timestart = 10 reporter.timeend = 20 reporter.timersync = 15 reporter.print_summary(10, '', '') reporter.print_summary(1, 'skipped', 'failed') out = stdout.getvalue() assert out.find('<printed>') > -1
def test_critical_debugging_flag(): outcome = Outcome(is_critical=True) r = ReprOutcome(outcome.make_repr()) assert r.is_critical
except Skipped, e: outcome = Outcome(skipped=str(e)) except (SystemExit, KeyboardInterrupt): raise except: e = sys.exc_info()[1] if isinstance(e, Failed) and e.excinfo: excinfo = e.excinfo else: excinfo = py.code.ExceptionInfo() if isinstance(self.item, py.test.collect.Function): fun = self.item.obj # hope this is stable code = py.code.Code(fun) excinfo.traceback = excinfo.traceback.cut( path=code.path, firstlineno=code.firstlineno) outcome = Outcome(excinfo=excinfo, setupfailure=False) if self.usepdb: if self.reporter is not None: self.reporter(repevent.ImmediateFailure(self.item, ReprOutcome(outcome.make_repr (self.config.option.tbstyle)))) import pdb pdb.post_mortem(excinfo._excinfo[2]) # XXX hmm, we probably will not like to continue from that # point raise SystemExit() outcome.stdout, outcome.stderr = self.item._getouterr() return outcome class ApigenExecutor(RunExecutor): """ Same as RunExecutor, but takes tracer to trace calls as