pytest-html

首先安装pytest-html库

python 复制代码
#执行命令 pytest --html=report.html ./pytest-html.py

import pytest
import logging
def test_pass():
    """用例通过"""
    assert True


def test_fail():
    """用例失败"""
    assert False

def test_error():
    """用例错误"""
    raise Exception("这是一个错误")

pytest.mark.skip(reason=" 这是一个跳过用例")
def test_skip():
    """skip用例"""
    assert True
logging.basicConfig(level=logging.debug)
def test_log():
    logging.info("这是一个info")# 日志级别顺序:由低到高:debug > info> warn >error
    logging.debug("这是一个debug")

报告样式

相关推荐
excel5 小时前
ES6 中函数的双重调用方式:fn() 与 fn\...``
前端
可乐爱宅着5 小时前
全栈框架next.js入手指南
前端·next.js
你的人类朋友6 小时前
什么是API签名?
前端·后端·安全
会豪8 小时前
Electron-Vite (一)快速构建桌面应用
前端
中微子8 小时前
React 执行阶段与渲染机制详解(基于 React 18+ 官方文档)
前端
唐某人丶8 小时前
教你如何用 JS 实现 Agent 系统(2)—— 开发 ReAct 版本的“深度搜索”
前端·人工智能·aigc
中微子8 小时前
深入剖析 useState产生的 setState的完整执行流程
前端
遂心_9 小时前
JavaScript 函数参数传递机制:一道经典面试题解析
前端·javascript
小徐_23339 小时前
uni-app vue3 也能使用 Echarts?Wot Starter 是这样做的!
前端·uni-app·echarts
RoyLin9 小时前
TypeScript设计模式:适配器模式
前端·后端·node.js