def write_result(self, row, actual, result): ws = self.active_sheet() if isinstance(row, int) and (2 <= row <= ws.max_row): ws.cell(row=row, column=do_config.get_int('excel', 'actual_col'), value=actual) ws.cell(row=row, column=do_config.get_int('excel', 'result_col'), value=result) self.wb.save(self.filename)
def write_case(self, row, actual, result): other_workbook = openpyxl.load_workbook(self.filename) if self.sheetname is None: other_worksheet = other_workbook.active else: other_worksheet = other_workbook[self.sheetname] if isinstance(row, int) and (2 <= row <= other_worksheet.max_row): other_worksheet.cell(row, do_config.get_int('excel', 'actual_col'), actual) other_worksheet.cell(row, do_config.get_int('excel', 'result_col'), result) other_workbook.save(filename=self.filename)
def write_result(self, row, actual, result): other_wb = load_workbook(self.filename) if self.sheetname is None: other_ws = other_wb.active else: other_ws = other_wb[self.sheetname] if isinstance(row, int) and (2 <= row <= other_ws.max_row): other_ws.cell(row=row, column=do_config.get_int("excel", "actual_col"), value=actual) other_ws.cell(row=row, column=do_config.get_int("excel", "result_col"), value=result) other_wb.save(self.filename) else: print("传入的行号有误,行号应大于1的整数")
def __init__(self): self.conn = pymysql.connect( host=do_config.get_value('mysql', 'host'), user=do_config.get_value('mysql', 'user'), password=do_config.get_value('mysql', 'password'), db=do_config.get_value('mysql', 'db'), port=do_config.get_int('mysql', 'port'), charset=do_config.get_value('mysql', 'charset'), cursorclass=pymysql.cursors.DictCursor) self.cursor = self.conn.cursor()
def __init__(self): self.conn = pymysql.connect( host="192.168.10.65", user=do_config.get_value("mysql", "user"), password=do_config.get_value("mysql", "password"), port=do_config.get_int("mysql", "port"), database=do_config.get_value("mysql", "database"), charset="utf8", cursorclass=pymysql.cursors.DictCursor) self.cursor = self.conn.cursor()
def write_result(self,row,actul,result): """ 同一个Workbook对象,如果将数据写入到多个表单中,那么只有最后一个表单能够写入成功 :param row: 行数 :param actul: 实际结果 :param result: 返回状态 :return: """ other_wb=load_workbook(self.filename) #指定文件 if self.sheetname is None: other_ws=other_wb.active else: other_ws=other_wb[self.sheetname] if isinstance(row,int) and (2<=row<=other_ws.max_row): other_ws.cell(row=row,column=do_config.get_int('hang','value1'),value=actul) other_ws.cell(row=row,column=do_config.get_int("hang","value2"),value=result) other_wb.save(self.filename) other_wb.close() else: print("你输入的行号有误")
import pymysql import random from scripts.handle_config import do_config start_mobile_dict = do_config.get_eval_data('mobile phone', 'start_mobile') host = do_config.get_value('mysql','host') user=do_config.get_value('mysql','user') password=do_config.get_value('mysql','password') db_hand=do_config.get_value('mysql','db_hand') end_mobile = do_config.get_value('mobile phone','end_mobile') db = db_hand + end_mobile[1:3] table_name_hand=do_config.get_value('mysql','table_name_hand') table_name =table_name_hand + end_mobile[0] port=do_config.get_int('mysql','port') # print(host,type(host),user,type(user),password,type(password),db,type(db),port,type(port)) class DoMysql: def __init__(self,db_name=None): self.db=db_name if self.db == None: self.conn = pymysql.connect(host=host, user=user, password=password, db=db, port=port, charset='utf8', cursorclass=pymysql.cursors.DictCursor) else: self.conn = pymysql.connect(host=host, user=user, password=password, db=self.db, port=port,
from scripts.constants import USER_ACCOUNTS_FILE_PATH, CASES_DIR from scripts.handle_user import generate_users_config if not os.path.exists(USER_ACCOUNTS_FILE_PATH): #如果用户账号所在文件不存在,则创建用户账号 generate_users_config() #1.创建套件 # one_suite = unittest.TestSuite() #2.加载用例 #创建加载器对象 # one_loader = unittest.TestLoader() # one_suite.addTest(one_loader.loadTestsFromModule(register)) one_suite = unittest.defaultTestLoader.discover(CASES_DIR, pattern='test*.py') #3.运行用例 report_name = do_config.get_value('report', 'report_html_name') + \ datetime.strftime(datetime.now(), "%Y%m%d%H%M%S") +'.html' report_full_path = os.path.join(REPORTS_DIR, report_name) # print(report_full_path) with open(report_full_path, mode='wb') as save_to_file: one_runner = HTMLTestRunnerNew.HTMLTestRunner( stream=save_to_file, verbosity=do_config.get_int('report', 'verbosity'), title=do_config.get_value('report', 'title'), description=do_config.get_value('report', 'description'), tester=do_config.get_value('report', 'tester')) one_runner.run(one_suite)
import os from openpyxl import load_workbook from scripts.handle_config import do_config from scripts.constants import DATAS_DIR actual_col=do_config.get_int('cases excel','actual_col') result_col=do_config.get_int('cases excel','result_col') mobile_sheet = do_config.get_value('mobile phone','mobile_sheet') class DoExcel(): """ 定义处理excel类 """ def __init__(self,file_name,sheet_name=None): self.file_name = file_name self.sheet_name = sheet_name def get_cases(self): """ 获取所有测试用例 :return: """ wb = load_workbook(self.file_name) if self.sheet_name is None: ws = wb.active else: ws = wb[self.sheet_name] head_data_tuple = tuple(ws.iter_rows(max_row=1,values_only=True))[0] one_list = [] for one_tuple in tuple(ws.iter_rows(min_row=2,values_only=True)):