Example #1
0
 def readExcel(self, fileName):
     # 打开文件
     workBook = xlrd.open_workbook(filePath('data', fileName))
     # sheet索引从0开始
     sheet1_content = workBook.sheet_by_index(0)
     # 获取总行数
     row = sheet1_content.nrows
     # 获取总列数
     #col = sheet1_content.ncols
     result = []
     for i in range(1, row):
         dict_i = dict(
             zip(sheet1_content.row_values(0),
                 sheet1_content.row_values(i)))
         dict_i['Data'] = json.loads(dict_i['Data'])
         dict_i['Header'] = json.loads(dict_i['Header'])
         if dict_i['IsRun'] == 'y':
             dict_i['Url'] = getUrl() + dict_i['Url']
             dict_i['Header']['OrganId'] = getOrgCode()
             dict_i['Data']['belongOrgId'] = getOrgCode()
             result.append(dict_i)
     return result
Example #2
0
 def readExcel(self, fileName):
     # 打开文件
     workBook = xlrd.open_workbook(filePath('data', fileName))
     # sheet索引从0开始
     sheet1_content = workBook.sheet_by_index(0)
     # 获取总行数
     row = sheet1_content.nrows
     # 获取总列数
     #col = sheet1_content.ncols
     result = []
     for i in range(1, row):
         dict_i = dict(
             zip(sheet1_content.row_values(0),
                 sheet1_content.row_values(i)))
         dict_i['Data'] = json.loads(dict_i['Data'])
         if dict_i['IsRun'] == 'y':
             if dict_i['CaseId'] == 'test_006':
                 dict_i['Data']['data']['ImgName'] = '1.jpg'
                 dict_i['Data']['data']['ImgBase64'] = imgBase('1.jpg')
             dict_i['Url'] = getUrl() + dict_i['Url']
             dict_i['Data']['orgcode'] = getOrgCode()
             result.append(dict_i)
     return result
Example #3
0
        # 获取总行数
        row = sheet1_content.nrows
        # 获取总列数
        #col = sheet1_content.ncols
        result = []
        for i in range(1, row):
            dict_i = dict(
                zip(sheet1_content.row_values(0),
                    sheet1_content.row_values(i)))
            dict_i['Data'] = json.loads(dict_i['Data'])
            if dict_i['IsRun'] == 'y':
                if dict_i['CaseId'] == 'test_006':
                    dict_i['Data']['data']['ImgName'] = '1.jpg'
                    dict_i['Data']['data']['ImgBase64'] = imgBase('1.jpg')
                dict_i['Url'] = getUrl() + dict_i['Url']
                dict_i['Data']['orgcode'] = getOrgCode()
                result.append(dict_i)
        return result


if __name__ == '__main__':
    # obj = OperationExcel()
    # for i in obj.readExcel('testdata.xlsx'):
    #     with open(filePath('data','teacherIdList.txt'),'a') as f:
    #         f.write(i['CaseId']+'|')
    #     print(i)
    with open(filePath('data', 'teacherIdList.txt'), 'r') as f:
        str = f.read()
        l = str.strip('|').split('|')
        print(l)
Example #4
0
 def dictYaml(self, fileDir='data', fileName='book.yaml'):
     with open(filePath(fileDir=fileDir, fileName=fileName),
               'r',
               encoding='utf-8') as f:
         return yaml.safe_load(f)
Example #5
0
 def readYaml(self):
     with open(filePath(), 'r', encoding='utf-8') as f:
         return list(yaml.safe_load_all(f))
Example #6
0
 def readDataValue(self, fileDir='config', fileName='dangdang.yaml'):
     '''获取列的具体值dictConfig()'''
     with open(filePath(fileDir=fileDir, fileName=fileName),
               'r',
               encoding="utf-8") as f:
         return yaml.safe_load(f)
Example #7
0
 def getSheet(self):
     book = xlrd.open_workbook(filePath('data', 'books.xlsx'))
     return book.sheet_by_index(0)
Example #8
0
import pytest, time, os, sys, shutil
sys.path.append(
    "C:\\Users\\DONGCHUAN\\AppData\\Roaming\\Python\\Python37\\site-packages")
p = os.path.join(os.path.dirname(__file__))
sys.path.append(p)
from common.public import filePath, mkdir, sendEmail

if __name__ == '__main__':
    now = time.strftime("%Y-%m-%d_%H-%M", time.localtime())
    path = filePath('report', now)
    mkdir(path)
    path = filePath('report', 'assets')
    mkdir(path)
    filedir = 'report/' + now
    path = filePath(filedir, '测试报告.html')
    path = "--html=" + path
    pytest.main([path])

    p = os.path.join(os.path.dirname(__file__), "report", "assets",
                     "style.css")
    p1 = os.path.join(os.path.dirname(__file__), "report", now, "assets",
                      "style.css")
    shutil.copy(p1, p)
    p = os.path.join(os.path.dirname(__file__), "report", "测试报告.html")
    p1 = os.path.join(os.path.dirname(__file__), "report", now, "测试报告.html")
    shutil.copy(p1, p)
    sendEmail()
	def getSheet(self):
		'''打开excel文件'''
		execl=xlrd.open_workbook(filePath('data','books.xlsx'))
		'''返回excel文件第一个sheet,将数据尽量放在第一个sheet里'''
		return execl.sheet_by_index(0)
Example #10
0
 def dicYaml(self, fileDir='config', fileName='books.yaml'):
     with open(filePath(fileDir=fileDir, filename=fileName),
               'r',
               encoding='utf-8') as f:
         return yaml.safe_load(f)
Example #11
0
 def dictYaml(self, fileDir='config', fileName='book.yaml'):
     with open(filePath(fileDir=fileDir, fileName=fileName),
               'r',
               encoding='utf-8') as f:
         return list(yaml.safe_load_all(f))
Example #12
0
	def getSheet(self):
		'''获取sheet(一般只会用一个sheet,会从下标获取)'''
		workbook = xlrd.open_workbook(filePath('data','dangdang.xls'))
		return workbook.sheet_by_index(0)
Example #13
0
 def readYaml(self):
     with open(filePath(fileDir='data', fileName='login.yaml'),
               'r',
               encoding='utf-8') as f:
         return list(yaml.safe_load_all(f))
Example #14
0
 def readYamlE(self, fileDir, fileName):
     with open(filePath(fileDir=fileDir, fileName=fileName),
               'r',
               encoding='utf-8') as f:
         return yaml.safe_load(f)
Example #15
0
 def readYaml(self):
     with open(filePath('data', 'ya.yaml'), 'r', encoding="utf-8") as f:
         return list(yaml.safe_load_all(f))
Example #16
0
 def getSheet(self):
     book = xlrd.open_workbook(filePath("data", "books.xlsx"))
     return book.sheet_by_index(0)