def append_result_files(self, dst_resultfile, kw_resultfile_list, dst_root='Testcase', childtag='Keyword'):
"""Append kw/system result files into a testcase result file"""
try:
finstring = ''
for kw_file in kw_resultfile_list:
if kw_file is not None and kw_file is not False:
tree = self.xml_utils().get_tree_from_file(kw_file)
self.root = tree.getroot()
for child in self.root:
if child.tag == childtag:
finstring = finstring+self.xml_utils().convert_element_to_string(child)
tc_string = ' '
if self.file_utils().fileExists(dst_resultfile):
tc_tree = ET.parse(dst_resultfile)
tc_root = tc_tree.getroot()
for tc_child in tc_root:
tc_string = tc_string+self.xml_utils().convert_element_to_string(tc_child)
finalresult = '\n'.join(['<{0}>'.format(dst_root), tc_string + finstring,
'</{0}>'.format(dst_root)])
with open(dst_resultfile, 'w') as resultfile:
resultfile.write(finalresult)
resultfile.flush()
resultfile.close()
except Exception, err:
print_info('unexpected error: {0}'.format(str(err)))
testcase_utils_class.py 文件源码
python
阅读 27
收藏 0
点赞 0
评论 0
评论列表
文章目录