Пример #1
0
 def __init__(self):
     # 设置日志目录
     c = ReadConfig.Config()
     self.console_output_level = c.get_log("console_level")
     self.file_output_level = c.get_log("file_level")
     self.pattern = c.get_log("pattern")
     self.formatter = logging.Formatter(self.pattern)
     self.resultPath = os.path.join(project_Dir(), "logs")
     self.log_file_name = c.get_log('file_name') if c and c.get_log('file_name') else 'output.log'  # 日志文件
     # self.backup_count = c.get_log('backup_count') if c and c.get_log('backup_count') else 5  # 保留的日志数量
     # 初始化
     self.logger = logging.getLogger()
     # 设置日志级别
     self.logger.setLevel(self.file_output_level)
     self.file_failure = int(c.get_log("file_failure"))
     listdir = [d for d in os.listdir(self.resultPath)]
     if listdir == [] :
         self.logPath = os.path.join(self.resultPath, str(datetime.now().strftime("%Y%m%d%H%M")))
         os.mkdir(self.logPath)
         listdir = [d for d in os.listdir(self.resultPath)]
     self.old_log_file_name = listdir[-1]
     self.new_log_file_name = str(datetime.now().strftime("%Y%m%d%H%M"))
     self.logPath = os.path.join(self.resultPath, self.old_log_file_name)
     if (int(self.new_log_file_name)-int(self.old_log_file_name)) > self.file_failure:
         self.logPath = os.path.join(self.resultPath, str(datetime.now().strftime("%Y%m%d%H%M")))
         os.mkdir(self.logPath)
Пример #2
0
 def __init__(self):
     c = ReadConfig.Config()
     self.backup_days = c.get_log("backup_days")
     self.del_path = os.path.join(project_Dir(), "results")
     if not os.path.exists(self.del_path):
         os.mkdir(self.del_path)
     self.delList = os.listdir(self.del_path)  # 需要删除目录下所有文件或文件夹列表
     self.log = MyLog.get_log()
     self.logger = self.log.get_logger()
Пример #3
0
    def __init__(self, excelPath, sheetName="Sheet1"):
        self.log = Log.Log()
        self.logger = self.log.get_logger()
        self.excelPath = excelPath
        self.sheetName = sheetName
        self.readConfig = ReadConfig.Config()
        # 读取config文件内测试数据存放位置与传入具体文件名称拼接而成--初始化Excel测试数据文件目录
        project_path = project_Dir()

        self.test_data_path = os.path.join(project_path, self.readConfig.get_path('Excel_data_path'), self.excelPath)
        # # 初始化ddt报告目录
        # self.report_path = os.path.join(self.log.get_result_path(), "ddt_report.xlsx")
        self.data = xlrd.open_workbook(self.test_data_path)
        self.table = self.data.sheet_by_name(self.sheetName)
        # 获取第一行作为key值
        self.keys = self.table.row_values(0)
        # 获取总行数
        self.rowNum = self.table.nrows
        # 获取总列数
        self.colNum = self.table.ncols
Пример #4
0
# -*- coding: utf-8 -*-
import unittest, sys, time, datetime
sys.path.append("..")
from base_method import configHttp
from base_method import ReadConfig
from base_method import configDB
from base_method.Log import MyLog
from base_method import Exceloperate
import urllib3
import requests
from public_method.login import loginByOpenid
# 禁用安全请求警告
urllib3.disable_warnings()
"""######实例化这个文件所要使用到的对象#####"""
#实例化读取配置文件对象
readconfig = ReadConfig.Config()
#实例化日志类对象
log = MyLog.get_log()
logger = log.get_logger()
MySql = configDB.Mysql()
filepath = "userDataInfo_API.xlsx"
sheetName = "设置用户科目组合"
data = Exceloperate.ExcelUtil(filepath, sheetName)
excel_test_data1 = data.read_excel_dict("case_number")


class Test_set_Subject(unittest.TestCase):
    '''用户设置科目组合'''
    @classmethod
    def setUpClass(self):
        self.apiname = "用户设置科目组合"
Пример #5
0
    msg.attach(att)
    try:
        smtp = smtplib.SMTP_SSL(smtpserver, port)
    except:
        smtp = smtplib.SMTP()
        smtp.connect(smtpserver, port)
    # 用户名密码
    smtp.login(sender, psw)
    smtp.sendmail(sender, receiver, msg.as_string())
    smtp.quit()
    print('test report email has send out !')


if __name__ == "__main__":
    all_case = add_case()   # 1加载用例
    # 生成测试报告的路径
    run_case(all_case)        # 2执行用例
    # 获取最新的测试报告文件
    report_path = os.path.join(cur_path, "test_report")  # 报告文件夹
    report_file = get_report_file(report_path)  # 获取最新的测试报告
    #邮箱配置
    from base_method import ReadConfig
    emailconfig = ReadConfig.Config()
    sender = emailconfig.get_email("sender")
    psw = emailconfig.get_email("mail_pass")
    smtp_server = emailconfig.get_email("mail_host")
    port = emailconfig.get_email("mail_port")
    receiver = emailconfig.get_email("receiver")
    send_mail(sender, psw, receiver, smtp_server, report_file, port)  # 4最后一步发送报告