pytest study

pytest

测试用例的识别与运行

测试文件:test_*.py 和 *_test.py 以test开头或结尾的文件

测试用例:Test*类包含的所有 test_*的方法(测试类不能带有__init__方法), 不在class中的所有test_*的方法

python 复制代码
def func(x):
    return x + 1
def test_answer():
    assert func(3) == 5

python执行

python 复制代码
import pytest


def func(x):
    return x + 1
def test_answer():
    assert func(3) == 5

#用python方式执行
if __name__ == "__main__":
    pytest.main(["test_pytest.py"])

资料获取方法

【留言777】

各位想获取源码等教程资料的朋友请 点赞 + 评论 + 收藏 ,三连!

三连之后我会在评论区挨个私信发给你们~

相关推荐
这里有鱼汤1 天前
小白必看:QMT里的miniQMT入门教程
后端·python
TF男孩2 天前
ARQ:一款低成本的消息队列,实现每秒万级吞吐
后端·python·消息队列
该用户已不存在2 天前
Mojo vs Python vs Rust: 2025年搞AI,该学哪个?
后端·python·rust
站大爷IP2 天前
Java调用Python的5种实用方案:从简单到进阶的全场景解析
python
用户8356290780512 天前
从手动编辑到代码生成:Python 助你高效创建 Word 文档
后端·python
c8i2 天前
python中类的基本结构、特殊属性于MRO理解
python
liwulin05062 天前
【ESP32-CAM】HELLO WORLD
python
Doris_20232 天前
Python条件判断语句 if、elif 、else
前端·后端·python
Doris_20232 天前
Python 模式匹配match case
前端·后端·python
这里有鱼汤2 天前
Python量化实盘踩坑指南:分钟K线没处理好,小心直接亏钱!
后端·python·程序员