安装

pip install TestLink-API-Python-client
#!/usr/bin/env Python
# -*- coding: utf-8 -*-
'''
Created on 2018年4月2日 @author: Brenda
''' import testlink
from com.pingan.test.util.config import Config url = 'http://tm.paic.com.cn/testlink/lib/api/xmlrpc/v1/xmlrpc.php'
key = 'a04a27098jnkkmeemme'
test_project_name = 'NTS-CFB-AMS' #testlink上的测试计划名称 def set_testlink_result(case_id):
'''
@param case_id: 测试案例ID
@return:
'''
def _deco(func):
def _func(self):
try:
func(self)
report_test_result(case_id, 'p')
except:
report_test_result(case_id, 'f')
raise
return _func
return _deco def report_test_result(test_case_id, test_result):
'''
@param test_case_id: 测试案例ID
@param test_result: 测试结果 pass、failed
@return:
'''
test_case_id = str(test_case_id)
test_case_id = test_case_id.replace(',', ',')
case_id_list = test_case_id.split(',')
#Config.set_test_plan_name('XXX版本回归测试')
if Config.test_plan_name == None:
pass
else:
for case_id in case_id_list:
tlc = testlink.TestlinkAPIClient(url, key)
test_plan = tlc.getTestPlanByName(test_project_name, Config.test_plan_name) if len(test_plan):
if isinstance(test_plan[0], dict):
test_plan_id = test_plan[0]['id']
# print test_plan, str(test_plan_id)
response = tlc.getBuildsForTestPlan(test_plan_id)
build_name = response[0]['name']
tlc.reportTCResult(testcaseid=case_id, testplanid=test_plan_id, buildname=build_name, status=test_result,notes='')
# print res[0]['operation'], res[0]['message']

python模块学习之testlink (自动回写测试案例执行结果到testlink)的更多相关文章

  1. 【转】Python模块学习 - fnmatch & glob

    [转]Python模块学习 - fnmatch & glob 介绍 fnmatch 和 glob 模块都是用来做字符串匹配文件名的标准库. fnmatch模块 大部分情况下使用字符串匹配查找特 ...

  2. 【目录】Python模块学习系列

    目录:Python模块学习笔记 1.Python模块学习 - Paramiko  - 主机管理 2.Python模块学习 - Fileinput - 读取文件 3.Python模块学习 - Confi ...

  3. Python模块学习filecmp文件比较

    Python模块学习filecmp文件比较 filecmp模块用于比较文件及文件夹的内容,它是一个轻量级的工具,使用非常简单.python标准库还提供了difflib模块用于比较文件的内容.关于dif ...

  4. Python模块学习

    6. Modules If you quit from the Python interpreter and enter it again, the definitions you have made ...

  5. python模块学习第 0000 题

    将你的 QQ 头像(或者微博头像)右上角加上红色的数字,类似于微信未读信息数量那种提示效果. 类似于图中效果: 好可爱>%<! 题目来源:https://github.com/Yixiao ...

  6. Python模块学习:logging 日志记录

    原文出处: DarkBull    许多应用程序中都会有日志模块,用于记录系统在运行过程中的一些关键信息,以便于对系统的运行状况进行跟踪.在.NET平台中,有非常著名的第三方开源日志组件log4net ...

  7. python模块学习心得

    初始模块 1.什么是模块 模块是用来实现某项功能的一大堆代码,为什么会有模块呢?过程式编程的时候为了减少程序员编程代码的重复性,就利用函数的调用减少了代码的重复性,但是某些时候程序会过于的庞大,我们会 ...

  8. 解惑Python模块学习,该如何着手操作...

    Python模块 晚上和朋友聊天,说到公司要求精兵计划,全员都要有编程能力.然后C.Java.Python-对于零基础入门的,当然是选择Python的人较多了.可朋友说他只是看了简单的语法,可pyth ...

  9. Python模块学习系列

    python模块-time python模块-datetime python模块-OS模块详解

随机推荐

  1. 【Web API]无法添加AttributeRoutes的解决方案

    1.按照微软官方文档,如果要使用AttributeRoutes,需要在APP_START里的WebApiConfig.cs的Register方法中添加一行:config.MapHttpAttribut ...

  2. inline-block,inline,block,table-cell,float

    float:left ---------------------------------------------------------------------------------------- ...

  3. python 打印日历

    import calendar as c'''x = c.monthcalendar(2017,11) 使用这个结果打印出日历 s = 1while s <= 7: print('周%d '%( ...

  4. Dubbo 系列(07-5)集群容错 - Mock

    Dubbo 系列(07-5)集群容错 - Mock [toc] Spring Cloud Alibaba 系列目录 - Dubbo 篇 1. 背景介绍 相关文档推荐: Dubbo 实战 - 服务降级 ...

  5. Git的安装配置

    Git是什么 Git是一款免费.开源的分布式版本控制系统,可以有效.高速的处理从很小到非常大的项目版本管理. 与常用的版本控制工具CVS.Subversion等不同的是它采用了分布式版本库的方式,不必 ...

  6. Python控制台输出带颜色方法

    书写格式,和相关说明如下: 举例: print('\033[0;32;40m欢迎使用学生选课系统\033[0m') try: num = int(input('请输入数字选择功能 :')) excep ...

  7. BZOJ 2238: Mst DFS序+KDtree

    明明可以用二维数点来做啊,网上为什么都是树剖+线段树呢 ? code: #include <cstdio> #include <cstring> #include <al ...

  8. python 发送请求

    data = {"a":1,"b":2} urllib2 get: get_data = urllib.urlencode(data) req_url = UR ...

  9. qq for linux tar.gz安装

    借用官网的一段话 QQ for Linux 怎么命令行安装和卸载 RPM版本 安装 ①打开控制台,使用管理员身份登录 :②在终端中输入命令“rpm –U package_name.rpm“ , pac ...

  10. shell中的空格【转载】

    1.定义变量时, =号的两边不可以留空格. eg: gender=femal————right gender =femal———–wrong gender= femal———–wrong gender ...