【发布时间】:2018-07-21 13:34:24
【问题描述】:
我想使用以下代码修改pytest报告的结果表的列:
from datetime import datetime
from py.xml import html
import pytest
@pytest.mark.optionalhook
def pytest_html_results_table_header(cells):
cells.insert(2, html.th('Description'))
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.description))
cells.insert(1, html.td(datetime.utcnow(), class_='col-time'))
cells.pop()
@pytest.mark.hookwrapper
def pytest_runtest_makereport(item, call):
outcome = yield
report = outcome.get_result()
report.description = str(item.function.__doc__)
要使用上面的代码,我正在尝试安装 py.xml。在使用pip install py.xml 时。 ,我收到以下错误消息:
找不到满足 py.xml 要求的版本(来自版本:) 找不到 py.xml 的匹配分布
请告诉我如何解决此问题
【问题讨论】:
-
pytest如果安装正确,将自动安装py。运行pip install pytest --upgrade刷新安装,缺少的包应该添加。
标签: python pytest pytest-html