安装

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. thinkphp 相关

    路径重写,既模式2 需要.htaccess文件放到index.php同级, http.config文件 中当前项目目录配置  AllowOverride All LoadModule rewrite_ ...

  2. Java 反射简介(转载)

    反射机制是什么 反射机制是在运行状态中,对于任意一个类,都能够知道这个类的所有属性和方法:对于任意一个对象,都能够调用它的任意一个方法和属性:这种动态获取的信息以及动态调用对象的方法的功能称为java ...

  3. 记录MNIST实现与理解

    之前半个月的时间几乎都在看理论书籍,最近两天开始撸代码,一个跟Hello World同级别的教程例子就出来了,那就是MNIST.实现代码应该很多地方都有: #!/usr/bin/env python ...

  4. Jenkins构建触发器的区别

    Build periodically:定时进行项目构建或执行(它不care源码是否发生变化),配置如下: 0 2 * * *  (每天2:00 必须build一次源码) 如果是要定时执行脚本,需要选择 ...

  5. Thrift报错:Error: Thrift compiler: Failed to translate files. Error: Cannot run program thrift error=2

    文章目录 报错: 原因: 解决: 报错: Error: Thrift compiler: Failed to translate files. Error: Cannot run program th ...

  6. 【刷题笔记】686. Repeated String Match

    题意 题目大意是,给两个字符串 A 和 B,问 B 是否能成为 A+A+A+...+A 的子字符串,如果能的话,那么最少需要多少个 A? 暴力解法 直接 A+A+...,到哪次 A 包含 B 了,就返 ...

  7. OSX 创建 randisk(或称 tmpfs)

    创建步骤: #!/bin/bash ramdisk_size_in_mb= mount_point=/private/tmp ramdisk_size_in_sectors=$((${ramdisk_ ...

  8. Codeforces 492D Vanya and Computer Game

    D. Vanya and Computer Game time limit per test 2 seconds memory limit per test 256 megabytes input s ...

  9. Centos7 安装rar,unrar,zip,unzip

    1.yum 安装unrar # yum install unrar rar命令 # rar a test.rar test.jpg test.png 这条命令是将test.jpg和test.png压缩 ...

  10. HTTP Request 422 Unprocessable Entity

    最近接了一个接口,在调用接口时,返回这个错误代码. 百度到的解释是:请求格式正确,但是由于含有语义错误,无法响应. 开始一直在纠结,语义错误到底是什么?对照了无数次参数名,传参方式,无解. 后来用Fi ...