背景
import pytest
def test_assume1():
assert 1 == 2
print('hello')
assert 2 == 3
if __name__ == '__main__':
pytest.main(['-sv', __file__])
- 这样的代码运行的时候并不会打印hello
- 同样后面的assert 2==3也不会去操作
- 而实际测试的时候我们经常性的会遇到要去多重断言的情况
安装
pip install pytest-assume
pip install git+https://github.com/astraw38/pytest-assume.git
介绍
https://pypi.org/project/pytest-assume/ 不要看,啥都没有
https://github.com/astraw38/pytest-assume github上也就讲了几句
- A pytest plugin that allows multiple failures per test
用法一、assume
import pytest
def test_assume2():
pytest.assume( 1 == 2 )
print