首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ANSI彩色文本不在pytest-html报告中显示

ANSI彩色文本不在pytest-html报告中显示
EN

Stack Overflow用户
提问于 2019-11-19 23:35:31
回答 1查看 405关注 0票数 0

在pytest html报告中,未正确显示ANSI颜色文本。但在控制台中,我可以看到没有任何issue.Please的输出请参阅我的conftest.py,并让我知道是否必须进行任何更改才能正确显示。

代码语言:javascript
复制
from datetime import datetime
from py.xml import html
import pytest
import json
import globals
from Process.RunProcess import RunProcess
from os import path
import sys
from ansi2html import Ansi2HTMLConverter
from ansi2html.converter import main, \
    ANSI_VISIBILITY_ON, ANSI_VISIBILITY_OFF, \
    ANSI_BLINK_SLOW, ANSI_BLINK_FAST, ANSI_BLINK_OFF, \
    ANSI_NEGATIVE_ON, ANSI_NEGATIVE_OFF, \
    ANSI_INTENSITY_INCREASED, ANSI_INTENSITY_REDUCED, ANSI_INTENSITY_NORMAL
from ansi2html.util import read_to_unicode


@pytest.mark.optionalhook
def pytest_html_results_table_header(cells):
    # cells.insert(2, html.th('Status_code'))
    cells.insert(1, html.th('Time', class_='sortable time', col='time'))
    cells.pop()


@pytest.mark.optionalhook
def pytest_html_results_table_row(report, cells):
    # cells.insert(2, html.td(report.status_code))
    cells.insert(1, html.td(datetime.utcnow(), class_='col-time'))
    cells.pop()


@pytest.mark.hookwrapper
def pytest_runtest_makereport(item, call):
    outcome = yield
    # Ansi2HTMLConverter(linkify=True).convert(outcome.get_result())
    report = outcome.get_result()
    # report.status_code = str(item.function)

请查看控制台输出和html报告与所附图片的区别。[

EN

回答 1

Stack Overflow用户

发布于 2020-03-26 18:36:26

对我来说,在我按照https://github.com/pytest-dev/pytest-html#ansi-codes中的描述安装了所需的依赖项ansi2html之后(不使用Ansi2HTMLConverter),它就能正常工作。然而,我并没有实现pytest_runtest_makereport钩子。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58937666

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档