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
相关推荐
姚青&6 天前
PyCharm 配置与界面化运行
pytest
姚青&6 天前
Pytest 测试用例断言
测试用例·pytest
姚青&6 天前
Pytest 命名规则
pytest
姚青&6 天前
Pytest 测试用例结构
测试用例·pytest
姚青&6 天前
Pytest 简介、安装与环境准备
pytest
测试渣7 天前
持续集成中的自动化测试框架优化实战指南
python·ci/cd·单元测试·自动化·pytest
小凯123458 天前
pytest框架-详解(学习pytest框架这一篇就够了)
python·学习·pytest
逻极8 天前
pytest 入门指南:Python 测试框架从零到一(2025 实战版)
开发语言·python·pytest