python 自定义断言

 
     #判断返回结果是否包含预期结果
    def is_contain(self,str_one,str_two):#判断str_one是否包含于str_two
        flag=None
        try:
            str_one.index(str_two)>1
        except:
            print('PASS!')
            flag=False
        return flag

     #判断两个字典是否相等
    def is_equal_dict(self,dict_one,dict_two):#判断两个字典值是否相等

        if isinstance(dict_one,dict_two):
            print('haha')
            dict_one =json.loads(dict_one)#str转成dict
            print(dict_two)
        else:
            print('oo')
        print(operator.eq(dict_one,dict_two))
 

 

猜你喜欢

转载自www.cnblogs.com/xiaozeng6/p/10992242.html