pytest pytest-html优化样式

conftest.py

python 复制代码
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

python 复制代码
[pytest]
addopts = -p no:warnings
render_collapsed = failed,error
相关推荐
思则变1 天前
[Pytest][Part 4]多种测试运行方式
pytest
程序员三藏1 天前
如何使用Pytest进行测试?
自动化测试·软件测试·python·测试工具·职场和发展·测试用例·pytest
一个处女座的测试3 天前
Python语言+pytest框架+allure报告+log日志+yaml文件+mysql断言实现接口自动化框架
python·mysql·pytest
思则变6 天前
[Pytest][Part 1]Pytest 自动化测试框架
pytest
思则变8 天前
[Pytest] [Part 2]增加 log功能
开发语言·python·pytest
思则变8 天前
[Pytest][Part 3]检测python package状态
pytest
cooldream200922 天前
pytest 框架详解与实战指南
pytest·测试
慕城南风22 天前
【pytest进阶】Pytest之conftest详解
pytest
编程小白gogogo23 天前
AI自动化测试速成(Pytest框架)
pytest