安装

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. (三)修改内核大小,适配目标板Nand flash分区配置

    一. 修改内核大小 1. 在你的配置文件下uboot/include/config/xxx.h 里面有一个宏定义 #define MTDPARTS_DEFAULT "mtdparts=jz2 ...

  2. swoole 多进程共享数据

    进程作为程序执行过程中资源分配的基本单位,拥有独立的地址空间,同一进程的线程可以共享本进程的全局变量,静态变量等数据和地址空间,但进程之间资源相互独立.由于PHP语言不支持多线程,因此Swoole使用 ...

  3. jQ无法设置checkbox变成选中状态

    设置以后checkbox并没有变成选中状态,用chrome调试看了一下,checkbox中确实有checked属性,针对这个问题,大家可以参考下本文 代码如下: $("input" ...

  4. 爬取拉勾网所有python职位并保存到excel表格 对象方式

    # 1.把之间案例,使用bs4,正则,xpath,进行数据提取. # 2.爬取拉钩网上的所有python职位. from urllib import request,parse import json ...

  5. 设置xampp开机自动启动

    l  设置xampp开机自动启动: 1)vi /etc/init.d/xampp.sh 增加:#!/bin/sh     /opt/lampp/lampp start 2)vi /etc/rc.d/r ...

  6. python基本数据类型集合set操作

    转:https://www.cnblogs.com/tina-python/p/5468495.html 一.集合的定义 set集合,是一个无序且不重复的元素集合. 集合对象是一组无序排列的可哈希的值 ...

  7. jQuery仿Android锁屏图案应用插件

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  8. Java原理领悟-线程池(Executor)

    线程池全面解析 什么是线程池? 很简单,简单看名字就知道是装有线程的池子,我们可以把要执行的多线程交给线程池来处理,和连接池的概念一样,通过维护一定数量的线程池来达到多个线程的复用. 线程池的好处 我 ...

  9. springcloud费话之Eureka基础

    目录: springcloud费话之Eureka基础 springcloud费话之Eureka集群 springcloud费话之Eureka服务访问(restTemplate) springcloud ...

  10. 关于dom获取元素的几种方式

    原文链接:https://blog.csdn.net/levinhax/article/details/71274456 获取元素DOM对象有很多种方法,以前一直在用getElementById和ge ...