2020-05-08 18:29:34 +08:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
# @Author : leizi
|
2020-05-09 21:24:18 +08:00
|
|
|
import unittest, os, datetime, time
|
2020-05-08 18:29:34 +08:00
|
|
|
from testCase.case import testinterface
|
|
|
|
|
from Public.py_Html import createHtml
|
|
|
|
|
from Public.get_excel import datacel
|
2020-05-09 21:24:18 +08:00
|
|
|
from Public.emmail import sendemali
|
2020-05-08 18:29:34 +08:00
|
|
|
from Public.create_report import save_result
|
2020-05-09 21:24:18 +08:00
|
|
|
import threading
|
|
|
|
|
|
|
|
|
|
|
2020-05-08 18:29:34 +08:00
|
|
|
def stast():
|
2020-05-09 21:24:18 +08:00
|
|
|
starttime = datetime.datetime.now()
|
|
|
|
|
day = time.strftime("%Y%m%d%H%M", time.localtime(time.time()))
|
|
|
|
|
basdir = os.path.abspath(os.path.dirname(__file__))
|
2020-05-08 18:29:34 +08:00
|
|
|
listid, listkey, listconeent, listurl, listfangshi, listqiwang, listname = datacel()
|
|
|
|
|
listrelust, list_fail, list_pass, list_json = testinterface()
|
2020-05-09 21:24:18 +08:00
|
|
|
filepath = os.path.join(basdir + '\\test_Report\\%s-result.html' % day)
|
2020-05-08 18:29:34 +08:00
|
|
|
if os.path.exists(filepath) is False:
|
|
|
|
|
os.system(r'touch %s' % filepath)
|
2020-05-09 21:24:18 +08:00
|
|
|
save_result(starttime, len(listrelust), ((list_pass)), list_fail)
|
|
|
|
|
endtime = datetime.datetime.now()
|
|
|
|
|
createHtml(titles='接口测试报告', filepath=filepath, starttime=starttime,
|
|
|
|
|
endtime=endtime, passge=list_pass, fail=list_fail,
|
|
|
|
|
id=listid, name=listname, key=listkey, coneent=listconeent, url=listurl, meth=listfangshi,
|
|
|
|
|
yuqi=listqiwang, json=list_json, relusts=listrelust)
|
2020-05-08 18:29:34 +08:00
|
|
|
# sendemali(filepath)
|
|
|
|
|
|
|
|
|
|
|
2020-05-09 21:24:18 +08:00
|
|
|
def tThread():
|
|
|
|
|
m = threading.Thread(target=stast, args=())
|
|
|
|
|
m.run()
|
2020-05-08 18:29:34 +08:00
|
|
|
|
|
|
|
|
|
2020-05-09 21:24:18 +08:00
|
|
|
if __name__ == '__main__':
|
|
|
|
|
tThread()
|