Mic*_*n09 2 html python pytest
我正在尝试使用 pytest 自定义 html 报告。例如,如果我有一个目录结构,如:
tests
temp1
test_temp1.py
conftest.py
Run Code Online (Sandbox Code Playgroud)
一个 conftest.py 文件也在测试目录中,它应该对测试目录中的所有子目录是通用的。我可以在 conftest.py 中使用哪些夹具和钩子包装器来更改使用以下命令生成的 html 文件的内容:
py.test 测试/temp1/test_temp1.py --html=report.html
更新:在最新版本中,如果您想修改html 报告中的环境表,请添加到您的conftest.py下一个代码中:
@pytest.fixture(scope='session', autouse=True)
def configure_html_report_env(request)
request.config._metadata.update(
{'foo': 'bar'}
)
Run Code Online (Sandbox Code Playgroud)