本文介绍: 对pytest友好输出详细展示。方便在回溯查看异常详情pytest对一些情况进行了特殊比较

官方实例

# content of test_assert2.py
import pytest

def test_set_comparison():
    set1 = set("1308")
    set2 = set("8035")
    assert set1 == set2
    

def test_dict_comparison():
    dict_1 = {'name':'陈畅','sex':'男'}
    dict_2 = {'name':'赵宁','sex':'女'}
    assert dict_1 == dict_2
    
def test_sring_comparison():
    str_1 = "compare dict"
    str_2 = "compare string"
    assert str_1 == str_2

解读实操

pytest对一些情况进行了特殊比较

在这里插入图片描述

场景应用

pytest友好输出详细展示。方便在回溯中查看异常详情

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注