test.html如何创建,如何自定义使用py.test生成的html报告文件?

看起来你使用的是像pytest-html这样的插件。 如果是这种情况检查该插件的文档提供了所有的钩子。

为pytest-HTML下面是提供的钩子 您可以添加从夹具修改request.config._html.environment改变报告的环境部分:

@pytest.fixture(autouse=True)

def _environment(request):

request.config._environment.append(('foo', 'bar'))

您可以通过创建一个“额外的细节添加到HTML报告'报告对象列表。下面的示例将不同类型的使用pytest_runtest_makereport钩群众演员,可以在一个插件或conftest.py文件来实现:

import pytest

@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':

# always add url to report

extra.append(pytest_html.extras.url('http://www.example.com/'))

xfail = hasattr(report, 'wasxfail')

if (report.skipped and xfail) or (report.failed and not xfail):

# only add additional html on failure

extra.append(pytest_html.extras.html('

Additional HTML
'))

report.extra = extra

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值