rednose.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:rednose 作者: JBKahn 项目源码 文件源码
def _format_traceback_line(self, tb):
        """
        Formats the file / lineno / function line of a traceback element.

        Returns None is the line is not relevent to the user i.e. inside the test runner.
        """
        if self._is_relevant_tb_level(tb):
            return None

        f = tb.tb_frame
        filename = f.f_code.co_filename
        lineno = tb.tb_lineno
        linecache.checkcache(filename)
        function_name = f.f_code.co_name

        line_contents = linecache.getline(filename, lineno, f.f_globals).strip()

        return "    %s line %s in %s\n      %s" % (
            termstyle.blue(self._relative_path(filename) if self.use_relative_path else filename),
            termstyle.bold(termstyle.cyan(lineno)),
            termstyle.cyan(function_name),
            line_contents
        )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号