def setUpClass(cls): cls.obj = None if datadriven.runtype == 'WEB': cls.obj = WEB(datadriven.writer) if datadriven.runtype == 'APP': cls.obj = APP(datadriven.writer) if datadriven.runtype == 'HTTP': cls.obj = HTTP(datadriven.writer) if datadriven.runtype == 'SOAP': cls.obj = SOAP(datadriven.writer)
def setUpClass(cls): """ 根据不同的用例类型,选择调用不同的关键字库 :return: """ cls.obj = None if datadriven.runtype == 'WEB': cls.obj = Web(datadriven.writer) if datadriven.runtype == 'APP': cls.obj = APP(datadriven.writer) if datadriven.runtype == 'HTTP': cls.obj = HTTP(datadriven.writer) if datadriven.runtype == 'SOAP': cls.obj = SOAP(datadriven.writer)
writer = Writer() writer.copy_open('./lib/%s.xls' % casename, './lib/result-%s.xls' % casename) sheetname = reader.get_sheets() writer.set_sheet(sheetname[0]) starttime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) writer.write(1, 3, starttime) reader.readline() casetype = reader.readline()[1] # 执行用例的关键字库对象 obj = None if casetype == 'HTTP' or casetype == '': # 执行http接口自动化 obj = HTTP(writer) elif casetype == 'SOAP': obj = SOAP(writer) elif casetype == 'WEB': obj = Web(writer) elif casetype == 'APP': obj = App(writer) for sheet in sheetname: # 设置当前读取的sheet页面 reader.set_sheet(sheet) # 读到哪个sheet页,写到哪个sheet页 writer.set_sheet(sheet) for i in range(reader.rows): line = reader.readline() # 读到哪一行,写到哪一行 obj.row = i if len(line[0]) > 0 or len(line[1]) > 0:
#获取开始时间 t = str(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))) #设置shet页 writer.set_sheet(sheetname[0]) # 写入结果文件 writer.write(1, 3, t) #识别接口类型 reader.readline() line = reader.readline() if line[1] == 'HTTP': http = HTTP(writer) elif line[1] == 'SOAP': http = SOAP(writer) elif line[1] == 'REST': http = REST(writer) elif line[1] == 'WEB': http = WEB(writer) else: http = APP(writer) for sheet in sheetname: # 设置当前读取的sheet页面 reader.set_sheet(sheet) writer.set_sheet(sheet) writer.clo = 7 for i in range(reader.rows): writer.row = i line = reader.readline() logger.info(line)