import pytest import os from pytest_assume.plugin import assume @pytest.mark.parametrize('x,y', [(1, 1), (2, 3)]) def test_1(x, y): assert x == y assert x > y assert x + 1 >= y print('测试完成') # 使用 pytest-assume 插件,取消断言失败后用例整体失败不继续执行问题 @pytest.mark.parametrize('x,y', [(1, 1), (2, 3)], ids=['case1', 'case2']) def test_2(x, y): pytest.assume(x == y) pytest.assume(x > y) pytest.assume(x + 1 >= y) print('测试完成') # 使用 with + assume 假设 执行,忽略断言失败继续执行 @pytest.mark.parametrize('x,y', [(1, 1), (2, 3)], ids=['case1', 'case2']) def test_3(x, y): with assume: assert x == y with assume: assert x > y with assume: assert x + 1 >= y print('测试完成') """ 使用如下: CMD 安装 pip install pytest-flakes CMD 执行 pytest --flakes .\02_pytest-flakes插件_静态代码检查.py """
pytest学习实践-day34:02_pytest-flakes插件_静态代码检查
最新推荐文章于 2024-10-06 20:54:02 发布