Esempio n. 1
0
def add_header(hkey, jkey):
    global json_res, session

    session.headers[hkey] = json_res[jkey]
    writer.write(reader.rr - 1, 7, 'PASS')
    writer.write(reader.rr - 1, 8, json_res[jkey])
    print('headers[%s]:' % (session.headers[hkey]), session.headers[hkey])
Esempio n. 2
0
def saveJson(jkey, key):
    global json_res, saveData
    print("正在保存参数------------------------------------")
    jsonStr = json_path(jkey)
    saveData[key] = jsonStr
    writer.write(reader.rr - 1, 7, 'PASS')
    writer.write(reader.rr - 1, 8, jsonStr)

    #print('the key is %s \nthe value is : %s'%(key,jsonStr))

    print("保存参数 %s 的值为%s " % (key, jsonStr))
Esempio n. 3
0
def get(url, param):
    global session, response  #引用全局变量
    #param_json()
    #调get发送请求
    #res=session.post(url,data=params,verify=False,timeout=30)
    res = session.get(url, data=param, verify=False, timeout=30)
    response = res.content.decode('utf8')
    writer.write(reader.rr - 1, 7, 'PASS')
    writer.write(reader.rr - 1, 8, response)

    print(response)
    #调用json_paser
    json_paser()
Esempio n. 4
0
def assert_equals(key, value):
    global json_res
    print(value)
    #转化为字符串
    if json_res[key].__str__() == value:
        print('PASS')
        writer.write(reader.rr - 1, 7, 'PASS')
        writer.write(reader.rr - 1, 8, value)
    else:
        print('Fail')
        writer.write(reader.rr - 1, 7, 'Fail')
        writer.write(reader.rr - 1, 8, json_res[key])
Esempio n. 5
0
def wirte_result(result, value):
    if reader.rr > 0:
        writer.write(reader.rr - 1, 7, result)
        writer.write(reader.rr - 1, 8, value)
Esempio n. 6
0
def saveJson(jkey, key):
    global json_res, saveparam
    saveparam[key] = json_res[jkey]
    writer.write(reader.rr - 1, 7, 'PASS')
    writer.write(reader.rr - 1, 8, json_res[jkey])
    print('保存%s 的值是: %s' % (key, json_res[jkey]))
Esempio n. 7
0
def seturl(url):
    global base_url
    base_url = url
    writer.write(reader.rr - 1, 7, 'PASS')
    writer.write(reader.rr - 1, 8, base_url)