将PNG图片添加到Pytest HTML报告中

我在通过pytest进行的每个测试中都创建了png图像,并且我也在使用pytest-html创建pytest报告。问题是,我不知道如何将这些png图像添加到pytest报告中。

我知道我可以在conftest.py中创建一个钩子,但是我不知道如何使用它并对其进行配置。我不了解“ item”和“ call”变量,而且我不确定如何链接png文件。

@pytest.mark.hookwrapper
def pytest_runtest_makereport(item,call):
    pytest_html = item.config.pluginmanager.getplugin('html')
    outcome = yield
    report = outcome.get_result()
    extra = getattr(report,'extra',[])
    if report.when == 'call':
        extra.png(image)
        report.extra = extra
xiyangfenghuang 回答:将PNG图片添加到Pytest HTML报告中

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3140840.html

大家都在问