pytest_syslog.py 文件源码

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

项目:taf 作者: taf3 项目源码 文件源码
def get_last_record_from_log(self, log, item):
        """Return last log records for TC.

        Args:
            log(str): log file
            item(pytest.Item): test case item

        Returns:
            str: Log related to specified test item

        """
        started = False

        tc_name = get_tcname(item)
        fin = open(log)

        lines = []
        while True:
            line = fin.readline()
            # EOF
            if line == "":
                break
            # Select last block "TC started ... TC finished" in log
            if not started:
                if tc_name in line and "started" in line:
                    started = True
                    lines = []
                    lines.append(line)
            else:
                lines.append(line)
                if tc_name in line and "finished" in line:
                    started = False
        fin.close()
        return " ".join(lines)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号