예제 #1
0
        def append_log_html(self, report, additional_html):
            log = html.div(class_="log")
            if report.longrepr:
                for line in report.longreprtext.splitlines():
                    separator = line.startswith("_ " * 10)
                    if separator:
                        log.append(line[:80])
                    else:
                        exception = line.startswith("E   ")
                        if exception:
                            log.append(
                                html.span(raw(escape(line)), class_="error"))
                        else:
                            log.append(raw(escape(line)))
                    log.append(html.br())

            for section in report.sections:
                header, content = map(escape, section)
                log.append(f" {header:-^80} ")
                log.append(html.br())

                if ansi_support():
                    converter = ansi_support().Ansi2HTMLConverter(
                        inline=False, escaped=False)
                    content = converter.convert(content, full=False)
                else:
                    content = _remove_ansi_escape_sequences(content)

                log.append(raw(content))
                log.append(html.br())

            if len(log) == 0:
                log = html.div(class_="empty log")
                log.append("No log output captured.")
            additional_html.append(log)
예제 #2
0
        def _populate_html_log_div(self, log, report):
            if report.longrepr:
                # longreprtext is only filled out on failure by pytest
                #    otherwise will be None.
                #  Use full_text if longreprtext is None-ish
                #   we added full_text elsewhere in this file.
                text = report.longreprtext or report.full_text
                for line in text.splitlines():
                    separator = line.startswith("_ " * 10)
                    if separator:
                        log.append(line[:80])
                    else:
                        exception = line.startswith("E   ")
                        if exception:
                            log.append(
                                html.span(raw(escape(line)), class_="error"))
                        else:
                            log.append(raw(escape(line)))
                    log.append(html.br())

            for section in report.sections:
                header, content = map(escape, section)
                log.append(f" {header:-^80} ")
                log.append(html.br())

                if ansi_support():
                    converter = ansi_support().Ansi2HTMLConverter(
                        inline=False, escaped=False)
                    content = converter.convert(content, full=False)
                else:
                    content = _remove_ansi_escape_sequences(content)

                log.append(raw(content))
                log.append(html.br())
예제 #3
0
def unansi(byte_string, as_list=True):
    """Remove ANSI escape sequences from pexpect output."""
    out = _remove_ansi_escape_sequences(byte_string.decode())
    if as_list:
        return out.split("\r\n")
    out