conftest.py
import pytest
from pytest_metadata.plugin import metadata_key
def pytest_html_report_title(report):
report.title="接口测试报告"
def pytest_configure(config):
# 获取命令行参数中的测试环境、测试版本、开始时间、测试人员
config.stash[metadata_key]["测试环境"] = 'K'
config.stash[metadata_key]["测试版本"] = 'V我50'
config.stash[metadata_key]["开始时间"] = strftime("%Y-%m-%d %H:%M:%S")
config.stash[metadata_key]["测试人员"] = '坤坤'
def pytest_html_results_summary(prefix, summary, postfix):
prefix.extend(["<p>涉及测试模块如:test1,test2</p>"])
默认展开log
pytest.ini
[pytest]
addopts = -p no:warnings
render_collapsed = failed,error