1 Star 0 Fork 4

阿甘/httptest-excel

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
run.py 1.83 KB
一键复制 编辑 原始数据 按行查看 历史
随风挥手 提交于 2022-04-24 22:12 . update
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
import os
import platform
import argparse
import unittest
from common.variables import VariablePool
from utils.send_mail import send_report_mail
from utils.HTMLTestRunner import HTMLTestRunner
from BeautifulReport import BeautifulReport
def running(path):
"""运行"""
test_case = unittest.defaultTestLoader.discover('tests', 'test*.py')
with open(path, 'wb') as fp:
runner = HTMLTestRunner(stream=fp,
title='Excel接口测试',
description="用例执行情况",
verbosity=2)
result = runner.run(test_case)
if result.failure_count:
send_report_mail(path)
def running(path):
test_case = unittest.defaultTestLoader.discover('tests', 'test*.py')
result = BeautifulReport(test_case)
result.report(
filename=os.path.basename(path),
description="测试报告")
def file_path(arg):
"""获取输入的文件路径"""
if 'Windows' in platform.platform():
_dir = os.popen('chdir').read().strip()
else:
_dir = os.popen('pwd').read().strip()
if _dir in arg:
return arg
return os.path.join(_dir, arg)
def main():
"""主函数"""
parser = argparse.ArgumentParser(description="运行Excel接口测试")
parser.add_argument('-i', type=str, help='原始文件')
parser.add_argument('-o', type=str, default='report.xlsx', help="输出文件")
parser.add_argument('-html', type=str, default='report.html', help="报告文件")
args = parser.parse_args()
VariablePool.set('excel_input', file_path(args.i))
VariablePool.set('excel_output', file_path(args.o))
VariablePool.set('report_path', file_path(args.html))
running(VariablePool.get('report_path'))
if __name__ == '__main__':
main()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/lancelottree/httptest-excel.git
git@gitee.com:lancelottree/httptest-excel.git
lancelottree
httptest-excel
httptest-excel
master

搜索帮助