【发布时间】:2020-03-15 04:28:24
【问题描述】:
在 pytest html 报告中,ANSI 彩色文本显示不正确。但是在控制台中,我可以毫无问题地看到输出。请查看我的conftest.py,如果我必须进行任何更改才能正确显示,请告诉我。
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报告的区别。[
【问题讨论】:
-
有人能回答我的问题吗,我非常期待得到答案。
标签: python html pytest ansi-colors