我希望使用以下代码修改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找到匹配的发行版
请告诉我如何解决这个问题。
发布于 2018-07-21 13:42:01
如果您正在寻找pylib xml模块,那么它是由pip install py提供的(通常是pytest的一个传递依赖项,所以您可能已经安装了它)
尽管如此,在逐步淘汰py时,您可能需要考虑使用不同的库:
注意:此库处于维护模式,不应在新代码中使用。
(来自自述)
https://stackoverflow.com/questions/51456603
复制相似问题