def _print_errors(self, tw): """Print any errors in the 'normal' Pytest style Args: tw (TerminalWriter): Pytest TW instance """ tw.line("Errors:", white=True, bold=True) # Sort of hack, just use this to directly extract the exception format. # If this breaks in future, just re-implement it e = FormattedExcinfo() lines = e.get_exconly(self.exce) for line in lines: tw.line(line, red=True, bold=True)
def toterminal(self, tw): """Print out a custom error message to the terminal.""" exc = self.exce.value context = exc.context if context: for title, item in context: tw.line(title + ":", white=True, bold=True) tw.line(textwrap.indent(item, " "), red=True) tw.line("") e = FormattedExcinfo() lines = e.get_exconly(self.exce) tw.line("Errors:", white=True, bold=True) for line in lines: tw.line(line, red=True, bold=True)