-
Notifications
You must be signed in to change notification settings - Fork 61
/
run.py
63 lines (53 loc) · 1.57 KB
/
run.py
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""
@project: apiAutoTest
@author: zy7y
@file: run.py
@ide: PyCharm
@time: 2022/02/27
@github: https://github.com/zy7y
@desc: 运行文件
"""
import os
import shutil
from loguru import logger
from test_main import rfc
from test_main import pytest
def run(email: bool = False, web: bool = False):
"""
启动测试
:param email: 是否发送邮件
:param web: 是否已服务形式打开报告(将忽略邮件服务)
:return:
"""
if os.path.exists("report/"):
shutil.rmtree(path="report/")
# 解决 issues 句柄无效
logger.remove()
file_path = rfc.get_config("$.file_path").current
logger.add(file_path["log"], enqueue=True, encoding="utf-8")
logger.info(
"""
_ _ _ _____ _
__ _ _ __ (_) / \\ _ _| |_ __|_ _|__ ___| |_
/ _` | '_ \\| | / _ \\| | | | __/ _ \\| |/ _ \\/ __| __|
| (_| | |_) | |/ ___ \\ |_| | || (_) | | __/\\__ \\ |_
\\__,_| .__/|_/_/ \\_\\__,_|\\__\\___/|_|\\___||___/\\__|
|_|
Starting ... ... ...
"""
)
pytest.main(args=[f'--alluredir={file_path["report"]}/data'])
if web:
# 自动以服务形式打开报告
os.system(f'allure serve {file_path["report"]}/data')
else:
# 本地生成报告
os.system(
f'allure generate {file_path["report"]}/data -o {file_path["report"]}/html --clean'
)
logger.success("报告已生成")
if email:
from core import EmailServe
EmailServe(rfc).serve()
if __name__ == "__main__":
run()