AppUi自动化框架main.py代码

from lib.path import APP_CASE, APP_REPORT, EMAIL_INFO
import unittest
from lib.appController import Controller
from BeautifulReport import BeautifulReport
from lib.sendmail_new import SendMail
from lib.tools import get_new_report, remove_report

user = EMAIL_INFO.get('user') # 从配置文件中获取邮件用户名
password = EMAIL_INFO.get('password') # 从配置文件中获取邮箱授权码
host = EMAIL_INFO.get('host') # 从配置文件中获取邮件服务器
to = EMAIL_INFO.get('to') # 从配置文件中获取邮件接收者
cc = EMAIL_INFO.get('cc') # 从配置文件中获取抄送邮箱
subject = EMAIL_INFO.get('subject') # 从配置文件中获取邮件标题
contents = EMAIL_INFO.get('contents') # 从配置文件中获取邮件内容
attachments = EMAIL_INFO.get('attachments') # 从配置文件中获取邮件


class Main(object):
def __init__(self):
self.controller = Controller()
self.deviceName = self.controller.deviceName

def run(self):
self.controller.start_server()
if self.controller.test_server():
print('111')
self.controller.start_driver()
print('222')
suit = unittest.TestSuite()
cases = unittest.defaultTestLoader.discover(APP_CASE)
for case in cases:
suit.addTest(case)
run = BeautifulReport(suit) # 实例化BeautifulReport模块
run.report(filename="{}.html".format(self.deviceName), description='用例执行情况', log_path=APP_REPORT)


if __name__ == '__main__':
m = Main()
m.run()
filename = get_new_report()
send = SendMail(user, password, host, to, cc, subject, contents, filename)
send.send_mail()
remove_report()
posted @ 2018-10-06 21:46  laosun0204  阅读(274)  评论(0编辑  收藏  举报