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
相关推荐
爆更小哇2 天前
pytest集成Allure报告教程
python·测试工具·pytest·接口测试·allure
gCode Teacher 格码致知2 天前
Python提高:pytest的简单案例-由Deepseek产生
python·pytest
gCode Teacher 格码致知3 天前
Python提高: unittest和 pytest的使用方法-由Deepseek产生
开发语言·python·pytest
我的xiaodoujiao6 天前
API 接口自动化测试详细图文教程学习系列11--Requests模块3--测试练习
开发语言·python·学习·测试工具·pytest
我的xiaodoujiao7 天前
API 接口自动化测试详细图文教程学习系列12--Requests模块4--测试实践操作
python·学习·测试工具·pytest
Lightning-py8 天前
pytest 软断言的几种方式
pytest
Lightning-py8 天前
pytest后置处理方式
pytest
爆更小哇10 天前
Python自动化测试:pytest新手快速入门指南
python·测试工具·自动化·pytest
qq_4523962310 天前
第一篇:基座选型 —— 为什么 Pytest 是自动化的终点?
自动化·pytest
时光不写代码11 天前
修复 pytest-asyncio 事件循环冲突:完整解决方案
python·pytest·fastapi