1

我想使用以下代码修改 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 的匹配分发

请让我知道如何解决此问题

4

1 回答 1

0

如果您正在寻找它提供的 pylib xml 模块pip install py(通常是 pytest 的传递依赖项,因此您可能已经安装了它)

也就是说,您可能需要考虑使用py正在逐步淘汰的其他库:

注意:此库处于维护模式,不应在新代码中使用。

(来自自述文件

于 2018-07-21T13:42:01.210 回答