예제 #1
0
        if len(headers_para):
            headers_data = pre_res["body"][headers_para[0]]
            # 替换结果
            headers = Base.res_sub(headers, headers_data)
        if len(cookies_para):
            cookies_para = pre_res["body"][cookies_para[0]]
            #替换结果
            cookies = Base.res_sub(headers, cookies_para)
        return headers, cookies

if __name__ == "__main__":
    # report_path = Conf.get_report_path()+os.sep+"result"
    # report_html_path = Conf.get_report_path()+os.sep+"html"
    # pytest.main(["-s","test_excel_case.py","--alluredir",report_path])

    Base.allure_report(report_path, report_html_path)
    # Base.allure_report("./report/result","./report/html")
    Base.send_mail(title="接口测试报告结果", content=report_html_path)
    #替换header变量
    #验证请求中是否${},返回${}$内容,
    # str1 = '{"Aythorization":"JWT ${token}$"}'
    # if "${" in str1:
    #     print(str1)
    # import re
    # patten = re.compile('\${(.*)}\$')
    # re_res = patten.findall(str1)
    # print(re_res[0])
    # # 根据内容token查找前置条件测试用例返回结果,
    # token = "123"
    # # 根据变结果内容进行替换
    # res = re.sub(patten,token,str1)
예제 #2
0
        Base.assert_db(db_name='db_1',
                       res_body=res['body'],
                       db_verify=db_verify)

    def get_correlation(self, headers, cookies, pre_res):
        """
        关联
        """
        # 验证是否有关联
        headers_para, cookies_para = Base.params_find(headers, cookies)
        # 有关联执行前置用例,获取结果
        if len(headers_para):
            headers_data = pre_res['body'][headers_para[0]]
            # 结果替换
            headers = Base.res_sub(headers, headers_data)

        if len(cookies_para):
            cookies_data = pre_res['body'][cookies_para[0]]
            # 结果替换
            cookies = Base.res_sub(headers, cookies_data)

        return headers, cookies


if __name__ == "__main__":
    report_path = Conf._report_path()
    pytest.main(
        ['-s', 'test_excel_case.py', '--alluredir', report_path + '/reslut'])
    Base.allure_report(report_path)
    # TestExcel().test_run()