def _print_stack_trace()

in testslide/runner.py [0:0]


    def _print_stack_trace(self, exception: BaseException, cause_depth: int) -> None:
        indent = "  " * cause_depth
        if cause_depth:
            self.print_red(f"{indent}    Caused by ", end="")

        self.print_red(
            "{exception_class}: {message}".format(
                exception_class=exception.__class__.__name__,
                message=f"\n{indent}    ".join(str(exception).split("\n")),
            )
        )

        tb = traceback.extract_tb(exception.__traceback__)

        test_module_index = self._get_test_module_index(tb)

        for index, (path, line, function_name, text) in enumerate(tb):
            if not self.show_testslide_stack_trace:
                if test_module_index is not None and index < test_module_index:
                    continue
                if os.path.abspath(path).startswith(self.TESTSLIDE_PATH):
                    continue
            if self.trim_path_prefix:
                split = path.split(self.trim_path_prefix)
                if len(split) == 2 and not split[0]:
                    path = split[1]
            row_text = (
                '  File "{path}", line {line}, in {function_name}\n'
                "    {text}\n".format(
                    path=path,
                    line=line,
                    function_name=function_name,
                    text=text,
                )
            )
            if self.colored:
                row_text = pygments.highlight(
                    row_text,
                    pygments.lexers.PythonTracebackLexer(),
                    pygments.formatters.TerminalFormatter(colorscheme=TS_COLORSCHEME),
                )
            row_text = "\n".join(
                "{indent}    {line}".format(indent=indent, line=line)
                for line in row_text.split("\n")[:-1]
            )
            print(row_text)

        if exception.__cause__:
            self._print_stack_trace(exception.__cause__, cause_depth=cause_depth + 1)