python测试框架之pytest (三)断言

一、pytest断言
Pytest中断言是通过 assert 语句实现的,确定预期值和实际值是否一致。

1.1、pytest等值类型断言

import allure

class TestAssert:
    @allure.story("pytest-assert方式")
    def test_equals(self):
        the_biscuit = "Ginger"
        my_biscuit = "Gingers"
        assert the_biscuit == my_biscuit

python测试框架之pytest (三)断言
1.2、pytest异常信息提示
如果想在异常的时候输出一些提示信息,这样报错后就方便查看是什么原因了。
def test_equals(self):
    the_biscuit = "Ginger"
    my_biscuit = "Gingerss"
    assert the_biscuit == my_biscuit, '这条用例失败了!'

python测试框架之pytest (三)断言
1.3、pytest集合类型断言
def test_dict(self):
    assert {
   "a": 0, "b": 1, "c"

Original: https://blog.csdn.net/weixin_44045851/article/details/122744059
Author: 大可MM
Title: python测试框架之pytest (三)断言

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/772283/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球