首先安装pytest-html库
#执行命令 pytest --html=report.html ./pytest-html.pyimport pytest
import logging
def test_pass():"""用例通过"""assert Truedef test_fail():"""用例失败"""assert Falsedef 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 >errorlogging.debug("这是一个debug")
报告样式