python读写将excel转换为xml_python:将excel转换xml(testlink)

#-*- coding: utf-8 -*-

from ExcelEg3 importExcelEg3importcopyclassTestStep:def __init__(self):

self._temp=ExcelEg3()

self._name= ''self._preconditions= ''self._actions= ''self._expected= ''self._steps= ['0']

self._testCases=[]

self._rows= 1self._step= {'step_number': '1','actions': '','expected': '','execution_type': 1}

self._testCase= {'name': '','summary': '','preconditions': '','execution_type': 1,'importance': 2,#'estimated_exec_duration': '',

'status': 1,'steps': []

}defset_name(self, row, col):

self._name=self._temp.get_cell_value(row, col)defget_name(self):returnself._namedefset_preconditions(self, row, col):

self._preconditions=self._temp.get_cell_value(row, col)defget_preconditions(self):returnself._preconditionsdefset_actions(self, row, col):

self._actions=self._temp.get_cell_value(row, col)defget_actions(self):returnself._actionsdefset_expected(self, row, col):

self._expected=self._temp.get_cell_value(row, col)defget_expected(self):returnself._expecteddefget_row_num(self):

self._rows=self._temp.get_rows()returnself._rowsdefset_step_value(self):

self._step['actions'] =copy.deepcopy(self.get_actions())

self._step['expected'] =copy.deepcopy(self.get_expected())defget_step(self):returnself._stepdefadd_step_to_steps(self, step4):

self._steps[0]=step4defget_steps(self):returnself._stepsdefset_test_case(self, steps):

self._testCase['name'] =self.get_name()

self._testCase['preconditions'] =self.get_preconditions()

self._testCase['steps'] =stepsdefget_test_case(self):returnself._testCasedefadd_tc_to_tcs(self, test_case):

self._testCases.append(test_case)defget_test_cases(self):returnself._testCasesdefadd_data(self):for row1 in range(1, self.get_row_num()):

self.set_name(row1, 0)

self.set_preconditions(row1,1)

self.set_actions(row1,2)

self.set_expected(row1,3)

self.set_step_value()

step2=copy.deepcopy(self.get_step())

self.add_step_to_steps(step2)

steps=copy.deepcopy(self.get_steps())

self.set_test_case(steps)#深赋值,更改字典的地址

test_case =copy.deepcopy(self.get_test_case())

self.add_tc_to_tcs(test_case)if __name__ == '__main__':

step=TestStep()

step.add_data()print('----------add get--------')print(step.get_test_cases()[0])

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值