日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

python实现xmind_Python xmind库(生成框架图)

發(fā)布時間:2024/7/23 python 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python实现xmind_Python xmind库(生成框架图) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

小編在測試日常工作中遇到一個費時的問題,如何將excel中的測試用例,生成測試框架圖?經(jīng)過查閱發(fā)現(xiàn)的python xmind庫

將excel中的測試用例,生成測試框架圖,分為2步

1.解析excel,取出excel中數(shù)據(jù)(此部分暫時忽略)

2.將前一步準(zhǔn)備的數(shù)據(jù)寫入 xmind(今天主要寫此部分)

一、前提條件:

二、代碼部分:

#!/usr/bin/env python

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

import sys

reload(sys)

sys.setdefaultencoding('utf8')

import xmind

from xmind.core import workbook,saver

from xmind.core.topic import TopicElement

def creatXmindFile(data):

module=[]

for item in data:

module.append(item['module'])

module=list(set(module))

w = xmind.load("test3.xmind") # load an existing file or create a new workbook if nothing is found

s2=w.createSheet() # create a new sheet

s2.setTitle("框架")

r2=s2.getRootTopic()

r2.setTitle("框架")

for i in range(len(module)):

t=TopicElement()

t.setTitle(module[i])

r2.addSubTopic(t)

w.addSheet(s2) # the second sheet is now added to the workbook

r2_topics=r2.getSubTopics() # to loop on the subTopics

for topic in r2_topics:

topic_name=topic.getTitle()

print topic_name

for item in data:

if topic_name == item['module']:

index=topic.getIndex()

t=TopicElement()

content=item['caseId']+" "+'\n'+item['summary']

t.setTitle(content)

r2_topics[index].addSubTopic(t)

summary=t.getTitle()

for item in data:

if item['summary'] in summary:

t1=TopicElement()

content1=item['name']

t1.setTitle(content1)

t.addSubTopic(t1)

xmind.save(w,"test3.xmind") # and we save

if __name__=='__main__':

data=[{

'name': 'testClickTheMenuButton',

'caseId': '01',

'module': '書架',

'summary': '多次開啟關(guān)閉書架',

}

, {

'name': 'testSearchWordWithoutResult',

'caseId': '02',

'module': '搜索',

'summary': '搜索無結(jié)果'

}]

creatXmindFile(data)

三、生成的xmind

11_gaitubao_com_922x437.png

總結(jié)

以上是生活随笔為你收集整理的python实现xmind_Python xmind库(生成框架图)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。