【问题标题】:Could not find a version that satisfies the requirement py.xml (from versions: ) No matching distribution found for py.xml找不到满足 py.xml 要求的版本(来自版本:)找不到 py.xml 的匹配分发
【发布时间】: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


【解决方案1】:

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

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

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

(来自the readme

【讨论】:

  • 感谢您的回复。由于 py 正在逐步淘汰,我需要安装哪个插件才能使用 html.th 和 html.td?
  • 您必须找到其他一些具有等效功能的库——我不知道html.X 的功能如何,但我认为任何流行的 xml 库都可以正常工作(或 stdlib 的简单包装器) html 甚至可能就足够了)
猜你喜欢
  • 2017-09-01
  • 2022-08-23
  • 1970-01-01
  • 2019-12-23
  • 1970-01-01
  • 2019-04-15
  • 2020-02-12
  • 2016-12-29
  • 1970-01-01
相关资源
最近更新 更多