示例#1
0
def run():
    print("开始执行程序 {}".format(
        datetime.datetime.now().strftime('%Y-%m-%d %H-%M-%S')))
    curPath = os.path.abspath(os.path.dirname(__file__))
    rootPath = curPath[:curPath.find("Eddid-News") + len("Eddid-News")]
    gm = GlobalMap()
    gm.set_List("errfunc", [])
    gm.set_value(nowtime=datetime.datetime.now().strftime('%Y-%m-%d %H-%M-%S'))

    pytest.main([
        "-s",
        "-v",
        "test_News.py",
        "--alluredir",
        rootPath + '/report/xml_{time}'.format(
            time=datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S')),
        "--reruns=2",  # pip install pytest-rerunfailures
        "--reruns-delay=2"
    ])
    xml_report_path, html_report_path = CommonsTool.rmdir5()
    print(xml_report_path)
    print(html_report_path)
    os.popen("allure generate {xml_report_path} -o {html_report_path} --clean".
             format(xml_report_path=xml_report_path,
                    html_report_path=html_report_path)).read()

    if gm.get_value("errfunc") != [] and gm.get_value("errfunc") != 'Null_':
        # 发送邮件提醒
        CommonsTool.send_email(gm.get_value("nowtime"),
                               gm.get_value("errfunc"))
        # 删除变量
        gm.del_map("errfunc")
        gm.del_map("errmsg")
    fix_routetitle = ["选择交易信息"]

    @pytest.mark.parametrize("reloadRoute", fix_routetitle, indirect=True)
    @allure.story("选择交易信息")
    def test_sendtransaction(self, poco, reloadRoute):
        pubTool = publicTool(poco)
        transac = transactionPage(poco)
        with allure.step("输入交易资金/财富来源"):
            employ = transac.click_fundsSource(["储蓄", "其他"])

        with allure.step("点击下一步"):
            pubTool.click_NextStepbtn()

        with allure.step("点击返回按钮返回账户信息界面"):
            pubTool.backform()
            assert_equal(pubTool.get_Routetitle(),
                         "选择交易信息",
                         msg="页面跳转到{}页面".format(pubTool.get_Routetitle()))


if __name__ == "__main__":
    pytest.main([
        "-s", "test_09_transaction.py::Test_transaction", '--alluredir',
        '../report/xml_{time}'.format(
            time=datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S'))
    ])
    xml_report_path, html_report_path = CommonsTool.rmdir5()
    os.popen("allure generate {xml_report_path} -o {html_report_path} --clean".
             format(xml_report_path=xml_report_path,
                    html_report_path=html_report_path)).read()