Ejemplo n.º 1
0
def _enter_pdb(node: Node, excinfo: ExceptionInfo[BaseException],
               rep: BaseReport) -> BaseReport:
    # 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  # type: ignore[attr-defined]
    post_mortem(tb)
    return rep
Ejemplo n.º 2
0
 def _outrep_summary(self, rep: BaseReport) -> None:
     rep.toterminal(self._tw)
     showcapture = self.config.option.showcapture
     if showcapture == "no":
         return
     for secname, content in rep.sections:
         if showcapture != "all" and showcapture not in secname:
             continue
         self._tw.sep("-", secname)
         if content[-1:] == "\n":
             content = content[:-1]
         self._tw.line(content)
Ejemplo n.º 3
0
def _get_line_with_reprcrash_message(config: Config, rep: BaseReport,
                                     termwidth: int) -> str:
    """Get summary line for a report, trying to add reprcrash message."""
    verbose_word = rep._get_verbose_word(config)
    pos = _get_pos(config, rep)

    line = f"{verbose_word} {pos}"
    line_width = wcswidth(line)

    try:
        # Type ignored intentionally -- possible AttributeError expected.
        msg = rep.longrepr.reprcrash.message  # type: ignore[union-attr]
    except AttributeError:
        pass
    else:
        available_width = termwidth - line_width
        msg = _format_trimmed(" - {}", msg, available_width)
        if msg is not None:
            line += msg

    return line
Ejemplo n.º 4
0
def _get_line_with_reprcrash_message(
    config: Config, rep: BaseReport, termwidth: int
) -> str:
    """Get summary line for a report, trying to add reprcrash message."""
    verbose_word = rep._get_verbose_word(config)
    pos = _get_pos(config, rep)

    line = "{} {}".format(verbose_word, pos)
    len_line = wcswidth(line)
    ellipsis, len_ellipsis = "...", 3
    if len_line > termwidth - len_ellipsis:
        # No space for an additional message.
        return line

    try:
        # Type ignored intentionally -- possible AttributeError expected.
        msg = rep.longrepr.reprcrash.message  # type: ignore[union-attr]
    except AttributeError:
        pass
    else:
        # Only use the first line.
        i = msg.find("\n")
        if i != -1:
            msg = msg[:i]
        len_msg = wcswidth(msg)

        sep, len_sep = " - ", 3
        max_len_msg = termwidth - len_line - len_sep
        if max_len_msg >= len_ellipsis:
            if len_msg > max_len_msg:
                max_len_msg -= len_ellipsis
                msg = msg[:max_len_msg]
                while wcswidth(msg) > max_len_msg:
                    msg = msg[:-1]
                msg += ellipsis
            line += sep + msg
    return line