Ai
1 Star 1 Fork 1

houjay/Python_Pytest_Allure

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
run_all_case.py 1.92 KB
一键复制 编辑 原始数据 按行查看 历史
houjay 提交于 2022-03-17 17:33 +08:00 . Python_Pytest_Allure_Seleinum
#!/usr/bin/python
# -*- coding: UTF-8 _*_
import os
import sys
import time
import pytest
from common import Shell
from common.Logs import Log
from common.Uploadfile import Uploadfile
from common.emails import mail
# dp = Uploadfile()
if __name__ == "__main__":
file = os.path.basename(sys.argv[0])
log = Log(file)
logger = log.Logger
# 运行单个文件 pytest.main(['../test_case/test_login.py']) 运行多个文件 pytest.main(['../test_case/test_login_getVar.py',
# '../test_case/test_login.py']) 运行整个目录 pytest.main(['../test_case', '--html=../report/report.html'])
# logger.info("开始执行脚本") >pytest F:\Python_Porject\Python_pytest_Allure\Run\run_all_case.py
# --alluredir=F:\\\Python_Porject\\Python_pytest_Allure\\allure-results\\ allure generate report -o report\\allure-reports\\
try:
print("开始执行脚本")
logger.info("==================================" + time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()) + "===================================")
pytest.main(["./test_case", "--alluredir", "./report/reportallure/"])
print("脚本执行完成")
except Exception as e:
logger.error("脚本批量执行失败!", e)
print("脚本批量执行失败!", e)
try:
shell = Shell.Shell()
cmd = 'allure generate %s -o %s --clean' % ('./report/reportallure/', './report/reporthtml/')
# logger.info("开始执行报告生成")
print("开始生成测试报告")
time.sleep(3)
shell.invoke(cmd)
# print(shell.invoke(cmd))
# logger.info("报告生成完毕")
print("报告生成完毕")
except Exception as e:
print("报告生成失败,请重新执行", e)
# logger.error("报告生成失败,请重新执行", e)
# log.error('执行用例失败,请检查环境配置')
raise
time.sleep(5)
# mail()
# dp.file_deploy()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/houjay/Python_Pytest_Allure.git
git@gitee.com:houjay/Python_Pytest_Allure.git
houjay
Python_Pytest_Allure
Python_Pytest_Allure
master

搜索帮助