def __init__(self, excel_name=None, has_title=True, result_file_name=None): if excel_name: ReadExcel.__init__(self, sheet_name=excel_name, has_title=has_title) else: ReadExcel.__init__(self, has_title=has_title) if result_file_name: WriteExcel.__init__(self, file_name=result_file_name) else: WriteExcel.__init__(self)
def __init__(self, excel_name="permutations.xlsx", has_title=True, result_file_name="permutation_result.xlsx"): if excel_name: ReadExcel.__init__(self, sheet_name=excel_name, has_title=has_title) else: ReadExcel.__init__(self, has_title=has_title) if result_file_name: WriteExcel.__init__(self, file_name=result_file_name) else: WriteExcel.__init__(self)
class RegisterTestCase(unittest.TestCase): excel = ReadExcel('cases.xlsx', 'Sheet1') # cases = excel.read_data() cases = excel.read_data_obj() def setUp(self): print('用例{}要开始执行了'.format(self)) def tearDown(self): print('用例{}要开始执行结束了'.format(self)) @data(*cases) def test_register(self, case): """正常注册""" # 预期结果: excepted = eval(case.excepted) # 参数:data data = eval(case.data) # 调用被测试的功能函数,传入参数,获取实际结果: res = register(*data) try: self.assertEqual(excepted, res) except AssertionError as e: print('该用例测试未通过') # 回写结果到excel文件中 self.excel.write_data(case.case_id + 1, 4, '未通过') raise e else: print('该用例测试通过') # 回写结果到excel文件中 self.excel.write_data(case.case_id + 1, 4, '通过')
def add_tersingkap_from_excel(self, loc, sheet): read_excel = ReadExcel(loc) read_excel.set_sheet(sheet) x = read_excel.cell_value(2, 4) y = read_excel.cell_value(3, 4) z = read_excel.cell_value(4, 4) self.tersingkap = Coordinate(x, y, z)
class RegisterTestCase(unittest.TestCase): """测试登录功能函数的测试用例类""" # cases = ReadExcel('cases.xlsx', 'cases').read_cases_obj() excel = ReadExcel('cases.xlsx', 'cases') cases = excel.read_cases_obj() def setUp(self): print('用例{}开始执行'.format(self)) def tearDown(self): print('用例{}执行结束'.format(self)) @data(*cases) def test_register(self, case): # '''注册模块的用例''' # 预期结果 excepted = eval(case.excepted) # print(excepted) # 入参参数data data = eval(case.data) # print(data) # 执行功能函数,获取实际结果 res = register_check(*data) try: # 对比预期结果和实际结果 self.assertEqual(excepted, res) except AssertionError as error: print('测试用例不通过') self.excel.write_data(case.case_id + 1, 4, 'failed') print('预期结果:{}'.format(excepted)) print('实际结果:{}'.format(res)) raise error else: print('测试用例通过') self.excel.write_data(case.case_id + 1, 4, 'passed') print('预期结果:{}'.format(excepted)) print('实际结果:{}'.format(res))
def add_structure_from_excel(self, loc, sheet): read_excel = ReadExcel(loc) read_excel.set_sheet(sheet) num_orientations = int(read_excel.cell_value(2, 1)) start_row = 4 for idx in range(num_orientations): row = start_row + idx strike_col = 0 dip_col = 1 strike = read_excel.cell_value(row, strike_col) dip = read_excel.cell_value(row, dip_col) plane_structure = PlaneStructure(strike, dip) linear_structure = plane_structure.get_linear_structure() self._structure.append(Structure(plane_structure, linear_structure)) self._avg_structure = copy.deepcopy(_get_avg_structure( self._structure))
============================ Author:柠檬班-木森 Time:2019/8/19 E-mail:[email protected] Company:湖南零檬信息技术有限公司 ============================ """ import unittest from HTMLTestRunnerNew import HTMLTestRunner from testcases import RegisterTestCase from read_excel import ReadExcel # 第一步:创建测试套件 suite = unittest.TestSuite() # 第二步:读取测试用例 cases = ReadExcel('cases.xlsx', 'Sheet1').read_data() # 第三步:加载用例到套件 for case in cases: suite.addTest( RegisterTestCase('test_register', case["excepted"], case["data"])) # 第四步:生成html文件的的测试报告 with open('zy_report.html', 'wb') as fb: runner = HTMLTestRunner(stream=fb, verbosity=2, title='柠檬班测试报告', description='这是我们21期的第一份报告作业', tester='MuSen') runner.run(suite)
def create_file_content(): return ReadExcel()
author:Administrator time:15:00 E-mail:[email protected] =============== ''' ddt:数据驱动思想 @ddt:装饰器 ''' """ import unittest from register import register_check from ddt import ddt, data from read_excel import ReadExcel # 读取测试用例 cases = ReadExcel('cases.xlsx', 'cases').read_cases() @ddt class RegisterTestCase(unittest.TestCase): """测试登录功能函数的测试用例类""" def setUp(self): print('用例{}开始执行'.format(self)) def tearDown(self): print('用例{}执行结束'.format(self)) # # @data(*cases) # def test(self,case): # print('测试用例{}执行'.format(case))
print('---------------------------------') print('Normal Vector Plane 1 : ') print(normal_vector_plane_1) print('Normal Vector Plane 2 : ') print(normal_vector_plane_2) print('Normal Vector Plane 3 : ') print(normal_vector_plane_3) # Get Coordinat Intersection intersection_coordinate = coordinate.get_intersection( normal_vector_plane_1, normal_vector_plane_2, normal_vector_plane_3) # Intersection Plane 1 Plane 2 Plane 3 dengan tunnel # TODO: Nama variabel ngga jelas read_excel = ReadExcel('data/alldata.xlsx') read_excel.set_sheet(5) roof_tunnel_coordinate = Coordinate(None, None, None) roof_tunnel_coordinate.z = read_excel.cell_value(1, 1) intersection_1_2_tunnel = get_intersection_normal_vector_with_tunnel( normal_vector_plane_1, normal_vector_plane_2, roof_tunnel_coordinate) intersection_1_3_tunnel = get_intersection_normal_vector_with_tunnel( normal_vector_plane_1, normal_vector_plane_3, roof_tunnel_coordinate) intersection_2_3_tunnel = get_intersection_normal_vector_with_tunnel( normal_vector_plane_2, normal_vector_plane_3, roof_tunnel_coordinate) # Read Line Equation from excel read_excel = ReadExcel('data/alldata.xlsx') read_excel.set_sheet(4)