deeptest执行接口脚本,添加python脚本断言

1.脚本断言,选择python

2.脚本代码

复制代码
import json
# 脚本断言
def compare(actual, expect):
	# 增加判断逻辑
    # actual为当前步骤响应结果封装
    # expect为期望结果封装
    # Struct类型为平台定义,详见帮助文档
    # json字符格式格式预处理,否则转json报错
    jstr = str(actual).replace('\\"','')
    jstr = jstr.replace('\\','')
    jsonObj = json.loads(jstr)
    # 遍历json集合数据
    dataList = jsonObj['result']['data']
    tempList = []
    print("length:",len(dataList))
    if len(dataList) > 0:
        for GoodsList in dataList:
            tmpValue = ""
            try:
                tmpValue = GoodsList['cid3Name']    
            except Exception as e:
                pass
                # print('异常数据:',GoodsList)
            tempList.append(tmpValue)
    print("cid3Name数据:",tempList)
    # 定义Bool变量
    ISflag = True
    if len(tempList) <=0 :
        ISflag = False
    print(ISflag)
    return ISflag;

断言成功,返回True, 失败则返回False

相关推荐
Object~9 分钟前
4.const和iota
开发语言·前端·javascript
HarmonLTS28 分钟前
Python Socket网络通信详解
服务器·python·网络安全
willingli29 分钟前
c语言经典100题 61-70题
c语言·开发语言·算法
我是小疯子6634 分钟前
深入解析C++右值引用与移动语义
java·开发语言·算法
Ethan Wilson36 分钟前
VS2019 C++20 模块相关 C1001: 内部编译器错误
开发语言·c++·c++20
郝学胜-神的一滴39 分钟前
Python数据封装与私有属性:保护你的数据安全
linux·服务器·开发语言·python·程序人生
悟能不能悟41 分钟前
Elastic Stack 中两种主要查询语言 KQL (Kibana Query Language) 和 Lucene 的详细对比和解释。
java·开发语言
智航GIS1 小时前
11.7 使用Pandas 模块中describe()、groupby()进行简单分析
python·pandas
Pyeako1 小时前
机器学习--矿物数据清洗(六种填充方法)
人工智能·python·随机森林·机器学习·pycharm·线性回归·数据清洗
赛恩斯1 小时前
kotlin 为什么可以在没有kotlin 环境的安卓系统上运行的
android·开发语言·kotlin