Python 测试框架:pytest 与 nose2 深度解析
1. 测试失败与 pytest 夹具
在测试过程中,我们可能会遇到测试失败的情况,例如:
E assert 3.5277031043732684e-204 > 0.05
testrand_1.py:28: AssertionError
------------------------------------------------ Captured stdout setup
-------------------------------------------------
Doing setUp
------------------------------------------------- Captured stdout call
-------------------------------------------------
Doing test_bad
========================================== 1 failed, 2 passed in 0.82
seconds ==========================================
这表明在 testrand_1.py 文件的第 28 行,断言 3.5277031043732684e-204 > 0.05 失败。
pytest 提供了夹具(fixtures)的概念,它允许我们定义一些在测试前或测试后执行的函
超级会员免费看
订阅专栏 解锁全文
342

被折叠的 条评论
为什么被折叠?



