Пример #1
0
def assert_in(asserqiwang,fanhuijson):
    if len(asserqiwang.split('=')) > 1:
        data = asserqiwang.split('&') #期望值可能出现多种&连接的值
        result = dict([(item.split('=')) for item in data]) #高级语法
        value1=([(str(res(fanhuijson,key))) for key in result.keys()])
        value2=([(str(value)) for value in result.values()])
        if value1==value2:
            return  { 'code':0,"result":'pass'}
        else:
            return {'code':1,'result':'fail'}
    else:
        LOG.info('填写测试预期值')
        return  {"code":2,'result':'填写测试预期值'}
Пример #2
0
def assert_in(asserqiwang, fanhuijson):
    """ assertqiwang的格式是:xx=yy """
    if len(asserqiwang.split(
            '=')) >= 1:  # xx.split('=') xx转换后的格式是:['xx', 'yy']
        data = asserqiwang.split('&')  # xx.split('&') xx转换后的格式是:['xx=yy']
        result = dict([(item.split('=')) for item in data
                       ])  # 此处是把 assertqiwang 转成 dict:{'xx': 'yy'}
        # result.keys() 表示result中的项; result.values()表示各项的值
        key = ([str(key) for key in result.keys()])[0]
        # value1 = ([(str(res(fanhuijson, key))) for key in result.keys()])
        value1 = res(fanhuijson, key)
        LOG.info('实际返回的值:{}'.format(value1))
        value2 = ([(str(value)) for value in result.values()])
        LOG.info('期望得到的结果:{}'.format(value2))
        if value1 == value2:
            return {'code': 200, "result": 'pass'}
        else:
            return {'code': 1001, 'result': 'fail'}
    else:
        LOG.info('填写测试预期值')
        return {"code": 1002, 'result': '填写测试预期值'}