首先安装html" title=pytest>pytest-html库
#执行命令 html" title=pytest>pytest --html=report.html ./html" title=pytest>pytest-html.py
import html" title=pytest>pytest
import logging
def test_pass():
"""用例通过"""
assert True
def test_fail():
"""用例失败"""
assert False
def test_error():
"""用例错误"""
raise Exception("这是一个错误")
html" title=pytest>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")
报告样式