예제 #1
0
def _enter_pdb(node, excinfo, rep):
    # XXX we re-use the TerminalReporter's terminalwriter
    # because this seems to avoid some encoding related troubles
    # for not completely clear reasons.
    tw = node.config.pluginmanager.getplugin("terminalreporter")._tw
    tw.line()

    showcapture = node.config.option.showcapture

    for sectionname, content in (
        ("stdout", rep.capstdout),
        ("stderr", rep.capstderr),
        ("log", rep.caplog),
    ):
        if showcapture in (sectionname, "all") and content:
            tw.sep(">", "captured " + sectionname)
            if content[-1:] == "\n":
                content = content[:-1]
            tw.line(content)

    tw.sep(">", "traceback")
    rep.toterminal(tw)
    tw.sep(">", "entering PDB")
    tb = _postmortem_traceback(excinfo)
    rep._pdbshown = True
    if post_mortem(tb):
        outcomes.exit("Quitting debugger")
    return rep
예제 #2
0
def _enter_pdb(node, excinfo, rep):
    # XXX we re-use the TerminalReporter's terminalwriter
    # because this seems to avoid some encoding related troubles
    # for not completely clear reasons.
    tw = node.config.pluginmanager.getplugin("terminalreporter")._tw
    tw.line()

    showcapture = node.config.option.showcapture

    for sectionname, content in (
        ("stdout", rep.capstdout),
        ("stderr", rep.capstderr),
        ("log", rep.caplog),
    ):
        if showcapture in (sectionname, "all") and content:
            tw.sep(">", "captured " + sectionname)
            if content[-1:] == "\n":
                content = content[:-1]
            tw.line(content)

    tw.sep(">", "traceback")
    rep.toterminal(tw)
    tw.sep(">", "entering PDB")
    tb = _postmortem_traceback(excinfo)
    rep._pdbshown = True
    if post_mortem(tb):
        outcomes.exit("Quitting debugger")
    return rep
예제 #3
0
 def addError(self, testcase, rawexcinfo):
     try:
         if isinstance(rawexcinfo[1], exit.Exception):
             exit(rawexcinfo[1].msg)
     except TypeError:
         pass
     self._addexcinfo(rawexcinfo)
예제 #4
0
 def addError(self, testcase: "unittest.TestCase",
              rawexcinfo: "_SysExcInfoType") -> None:
     try:
         if isinstance(rawexcinfo[1], exit.Exception):
             exit(rawexcinfo[1].msg)
     except TypeError:
         pass
     self._addexcinfo(rawexcinfo)
예제 #5
0
 def report_unexpected_exception(self, out, test, example, exc_info):
     if isinstance(exc_info[1], Skipped):
         raise exc_info[1]
     if isinstance(exc_info[1], bdb.BdbQuit):
         outcomes.exit("Quitting debugger")
     failure = doctest.UnexpectedException(test, example, exc_info)
     if self.continue_on_failure:
         out.append(failure)
     else:
         raise failure
예제 #6
0
                def set_quit(self):
                    """Raise Exit outcome when quit command is used in pdb.

                    This is a bit of a hack - it would be better if BdbQuit
                    could be handled, but this would require to wrap the
                    whole pytest run, and adjust the report etc.
                    """
                    super(_PdbWrapper, self).set_quit()
                    if cls._recursive_debug == 0:
                        outcomes.exit("Quitting debugger")
예제 #7
0
                def set_quit(self):
                    """Raise Exit outcome when quit command is used in pdb.

                    This is a bit of a hack - it would be better if BdbQuit
                    could be handled, but this would require to wrap the
                    whole pytest run, and adjust the report etc.
                    """
                    super(_PdbWrapper, self).set_quit()
                    if cls._recursive_debug == 0:
                        outcomes.exit("Quitting debugger")
예제 #8
0
            def do_quit(self, arg):
                """Raise Exit outcome when quit command is used in pdb.

                This is a bit of a hack - it would be better if BdbQuit
                could be handled, but this would require to wrap the
                whole pytest run, and adjust the report etc.
                """
                ret = super().do_quit(arg)

                if cls._recursive_debug == 0:
                    outcomes.exit("Quitting debugger")

                return ret
예제 #9
0
def post_mortem(t):
    class Pdb(pytestPDB._pdb_cls):
        def get_stack(self, f, t):
            stack, i = pdb.Pdb.get_stack(self, f, t)
            if f is None:
                i = _find_last_non_hidden_frame(stack)
            return stack, i

    p = Pdb()
    p.reset()
    p.interaction(None, t)
    if p.quitting:
        outcomes.exit("Quitting debugger")
예제 #10
0
def post_mortem(t):
    class Pdb(pytestPDB._pdb_cls, object):
        def get_stack(self, f, t):
            stack, i = super(Pdb, self).get_stack(f, t)
            if f is None:
                i = _find_last_non_hidden_frame(stack)
            return stack, i

    p = Pdb()
    p.reset()
    p.interaction(None, t)
    if p.quitting:
        outcomes.exit("Quitting debugger")
예제 #11
0
 def report_unexpected_exception(
     self,
     out,
     test: "doctest.DocTest",
     example: "doctest.Example",
     exc_info: Tuple[Type[BaseException], BaseException, types.TracebackType],
 ) -> None:
     if isinstance(exc_info[1], OutcomeException):
         raise exc_info[1]
     if isinstance(exc_info[1], bdb.BdbQuit):
         outcomes.exit("Quitting debugger")
     failure = doctest.UnexpectedException(test, example, exc_info)
     if self.continue_on_failure:
         out.append(failure)
     else:
         raise failure
예제 #12
0
 def raise_exit(obj):
     outcomes.exit("Quitting debugger")
예제 #13
0
def post_mortem(t):
    p = pytestPDB._init_pdb("post_mortem")
    p.reset()
    p.interaction(None, t)
    if p.quitting:
        outcomes.exit("Quitting debugger")
예제 #14
0
 def set_quit(self):
     super(_PdbWrapper, self).set_quit()
     outcomes.exit("Quitting debugger")
예제 #15
0
def post_mortem(t):
    p = pytestPDB._init_pdb("post_mortem")
    p.reset()
    p.interaction(None, t)
    if p.quitting:
        outcomes.exit("Quitting debugger")
예제 #16
0
 def raise_exit(obj):
     outcomes.exit("Quitting debugger")