run.py
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time : 2022/12/8 21:52
# @Author : Shitou
# @FileName: run.py
# @Software: PyCharm
import unittest
from unittestreport import TestRunner
from common.handle_path import TestCase_Path, Report_Path
from common.handle_config import conf
# 创建测试套件
suite = unittest.TestSuite()
# 加载用例
# ---创建加载器
load = unittest.TestLoader()
# ---用例放到加载器
suite.addTest(load.discover(TestCase_Path))
# 运行
runner = TestRunner(suite=suite,
filename=conf.get("report", "filename"),
report_dir=Report_Path,
title=conf.get("report", "title"),
tester=conf.get("report", "tester"),
desc=conf.get("report", "desc"),
templates=conf.getint("report", "templates")
)
runner.run()
# 执行失败重新运行机制
# runner.rerun_run(count=2, interval=3)
"""
发送邮件
"""
# QQ邮箱SMTP服务器地址为“smtp.qq.com”
# 163邮箱smtp.163.com 465
# 阿里云smtp.qiye.aliyun.com 465
runner.send_email(host="smtp.qiye.aliyun.com",
port=465,
user="shishut@workai.com.cn",
password="mKh50p89DqvqJ7pd",
to_addrs=["1171621168@qq.com", "shishut@workai.com.cn"]
)