17-pytest-pytest-assume多重校验

目录

前言

安装

使用


前言

  • 当一个用例中有多个断言时,一个断言失败,还想继续执行后面的断言,使用pytest-assume可实现这个需求

安装

  • pip install pytest-assume

使用

# -*- coding: utf-8 -*-
# @Time    : 2021/10/30
# @Author  : 大海
# @File    : test_36.py

import pytest

# 断言失败后的不会执行
def test_add():
    assert 1 + 1 == 2
    assert 1 + 2 == 4
    assert 1 + 3 == 4
    print('全部执行完成!')

# 断言失败,会继续执行后面的断言
def test_add2():
    pytest.assume(1 + 1 == 2)
    pytest.assume(1 + 2 == 4)
    pytest.assume(1 + 3 == 4)
    print('全部执行完成!')


if __name__ == '__main__':
    pytest.main(['-s', 'test_36.py'])

猜你喜欢

转载自blog.csdn.net/IT_heima/article/details/121047092