Esempio n. 1
0
 def check_file(self):
     reportpath = os.path.join(getPath.get_basepath(), 'result',
                               'report.html')
     if os.path.isfile(reportpath) and not os.stat(reportpath) == 0:
         return True
     else:
         return False
Esempio n. 2
0
    def __init__(self):
        global logPath, resultPath, proDir
        proDir = getPath.get_basepath()
        resultPath = os.path.join(proDir, "result")
        # create result file if it doesn't exist
        if not os.path.exists(resultPath):
            os.mkdir(resultPath)
        # defined test result file name by localtime
        logPath = os.path.join(resultPath,
                               str(datetime.now().strftime("%Y%m%d%H%M%S")))
        # create test result file if it doesn't exist
        if not os.path.exists(logPath):
            os.mkdir(logPath)
        # defined logger
        self.logger = logging.getLogger()
        # defined log level
        self.logger.setLevel(logging.INFO)

        # defined handler
        handler = logging.FileHandler(os.path.join(logPath, "out.log"))
        # defined formatter
        formatter = logging.Formatter(
            '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
        # defined formatter
        handler.setFormatter(formatter)
        # add handler
        self.logger.addHandler(handler)
Esempio n. 3
0
 def config_file(self):
     #如果有文件,就配置邮件附件  filename 用英文形式,如果用中文 需要改动
     if self.check_file():
         htmlpath = os.path.join(getPath.get_basepath(),'result','report.html')
         html = open(htmlpath,'rb').read()
         filehtml = MIMEText(html,'base64','utf-8')
         filehtml['Content-Type'] = 'application/octet-stream'
         filehtml['Content-Disposition'] = 'attachment; filename="test.html"'
         self.msg.attach(filehtml)
Esempio n. 4
0
import os
import getPath
from xlrd import open_workbook

basepath = getPath.get_basepath()
class ReadExcel():
    def get_xls(self,xls_name,sheet_name):
        cls = []
        #拼接文件路径
        xlsPath = os.path.join(basepath,'test_file','case',xls_name)
        #打开文件  login.xls
        file = open_workbook(xlsPath)
        #获取sheet  也就是 login.xls文件的 sheet名字
        sheet = file.sheet_by_name(sheet_name)
        #获取行数
        nrows = sheet.nrows
        for i in range(nrows):
            if sheet.row_values(i)[0] != u'case_name':
                #获取整行 整列的值  返回必须是数字 所以上面有空的 cls数组
                cls.append(sheet.row_values(i))
        return cls
Esempio n. 5
0
import os
import configparser
import getPath as getpath

#获取文件路径
basepath = getpath.get_basepath()
config_path = os.path.join(basepath, 'config\config.ini')
config = configparser.ConfigParser()
config.read(config_path)


class ReadConfig():
    #获取名字为 [HTTP] 的属性值
    def get_http(self, name):
        value = config.get('HTTP', name)
        return value

    def get_email(self, name):
        value = config.get('EMAIL', name)
        return value

    def get_database(self, name):
        value = config.get('DATABASE', name)
        return value