Exemple #1
0
    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
Exemple #2
0
                    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
    an argument to execute
    """
    def execute(self, tracer):
        self.tracer = tracer
        return super(ApigenExecutor, self).execute()

    def wrap_underlaying(self, target, *args):
        try:
            self.tracer.start_tracing()
            return target(*args)
        finally: