#-*- coding: utf-8 -*-
"""
A TestRunner for use with the Python unit testing framework. It
generates a HTML report to show the result at a glance.
The simplest way to use this is to invoke its main method. E.g.
import unittest
import HTMLTestRunner
... define your tests ...
if __name__ == '__main__':
HTMLTestRunner.main()
For more customization options, instantiates a HTMLTestRunner object.
HTMLTestRunner is a counterpart to unittest's TextTestRunner. E.g.
# output to a file
fp = file('my_report.html', 'wb')
runner = HTMLTestRunner.HTMLTestRunner(
stream=fp,
title='My unit test',
description='This demonstrates the report output by HTMLTestRunner.'
)
# Use an external stylesheet.
# See the Template_mixin class for more customizable options
runner.STYLESHEET_TMPL = '<link rel="stylesheet" href="my_stylesheet.css" type="text/css">'
# run the test
runner.run(my_test_suite)
------------------------------------------------------------------------
Copyright (c) 2004-2007, Wai Yip Tung
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name Wai Yip Tung nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""
# URL: http://tungwaiyip.info/software/HTMLTestRunner.html
__author__ = "Wai Yip Tung"
__version__ = "0.8.3"
"""
Change History
Version 0.8.4 by GoverSky
* Add sopport for 3.x
* Add piechart for resultpiechart
* Add Screenshot for selenium_case test
* Add Retry on failed
Version 0.8.3
* Prevent crash on class or module-level exceptions (Darren Wurf).
Version 0.8.2
* Show output inline instead of popup window (Viorel Lupu).
Version in 0.8.1
* Validated XHTML (Wolfgang Borgert).
* Added description of test classes and test cases.
Version in 0.8.0
* Define Template_mixin class for customization.
* Workaround a IE 6 bug that it does not treat <script> block as CDATA.
Version in 0.7.1
* Back port to Python 2.3 (Frank Horowitz).
* Fix missing scroll bars in detail log (Podi).
"""
# TODO: color stderr
# TODO: simplify javascript using ,ore than 1 class in the class attribute?
import datetime
import sys
import unittest
from xml.sax import saxutils
PY3K = (sys.version_info[0] > 2)
if PY3K:
import io as StringIO
else:
import StringIO
import copy
# ------------------------------------------------------------------------
# The redirectors below are used to capture output during testing. Output
# sent to sys.stdout and sys.stderr are automatically captured. However
# in some cases sys.stdout is already cached before HTMLTestRunner is
# invoked (e.g. calling logging_demo.basicConfig). In order to capture those
# output, use the redirectors for the cached stream.
#
# e.g.
# >>> logging_demo.basicConfig(stream=HTMLTestRunner.stdout_redirector)
# >>>
class OutputRedirector(object):
""" Wrapper to redirect stdout or stderr """
def __init__(self, fp):
self.fp = fp
def write(self, s):
self.fp.write(s)
def writelines(self, lines):
self.fp.writelines(lines)
def flush(self):
self.fp.flush()
stdout_redirector = OutputRedirector(sys.stdout)
stderr_redirector = OutputRedirector(sys.stderr)
# ----------------------------------------------------------------------
# Template
class Template_mixin(object):
"""
Define a HTML template for report customerization and generation.
Overall structure of an HTML report
HTML
+------------------------+
|<html> |
| <head> |
| |
| STYLESHEET |
| +----------------+ |
| | | |
| +----------------+ |
| |
| </head> |
| |
| <body> |
| |
| HEADING |
| +----------------+ |
| | | |
| +----------------+ |
| |
| REPORT |
| +----------------+ |
| | | |
| +----------------+ |
| |
| ENDING |
| +----------------+ |
| | | |
| +----------------+ |
| |
| </body> |
|</html> |
+------------------------+
"""
STATUS = {
0: u'通过',
1: u'失败',
2: u'错误',
}
DEFAULT_TITLE = 'Unit Test Report'
DEFAULT_DESCRIPTION = ''
# ------------------------------------------------------------------------
# HTML Template
HTML_TMPL = r"""<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>%(title)s</title>
<meta name="generator" content="%(generator)s"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
%(stylesheet)s
</head>
<body>
<script language="javascript" type="text/javascript">
output_list = Array();
/* level - 0:Summary; 1:Failed; 2:All */
function showCase(level) {
trs = document.getElementsByTagName("tr");
for (var i = 0; i < trs.length; i++) {
tr = trs[i];
id = tr.id;
if (id.substr(0,2) == 'ft') {
if (level < 1) {
tr.className = 'hiddenRow';
}
else {
tr.className = '';
}
}
if (id.substr(0,2) == 'pt') {
if (level > 1) {
tr.className = '';
}
else {
tr.className = 'hiddenRow';
}
}
}
}
function showClassDetail(cid, count) {
var id_list = Array(count);
var toHide = 1;
for (var i = 0; i < count; i++) {
tid0 = 't' + cid.substr(1) + '.' + (i+1);
tid = 'f' + tid0;
tr = document.getElementById(tid);
if (!tr) {
tid = 'p' + tid0;
tr = document.getElementById(tid);
}
id_list[i] = tid;
if (tr.className) {
toHide = 0;
}
}
for (var i = 0; i < count; i++) {
tid = id_list[i];
if (toHide) {
document.getElementById(tid).className = 'hiddenRow';
}
else {
document.getElementById(tid).className = '';
}
}
}
function showTestDetail(div_id){
var details_div = document.getElementById(div_id)
var displayState = details_div.style.display
// alert(displayState)
if (d
没有合适的资源?快使用搜索试试~ 我知道了~
python禅道登陆接口自动化实战
共79个文件
pyd:25个
py:13个
exe:7个
5星 · 超过95%的资源 需积分: 36 43 下载量 200 浏览量
2018-05-22
18:55:37
上传
评论 2
收藏 6.14MB ZIP 举报
温馨提示
python针对禅道登陆接口的自动化测试,+unittest+ddt接口自动化数据驱动并生成中文版的html报告;第一次写接口自动化的测试,学到很多东西,有不懂的客户加微信
资源推荐
资源详情
资源评论
收起资源包目录
InterfaceOne.zip (79个子文件)
InterfaceOne
__init__.py 1KB
report
result.xlsx 11KB
result.html 77KB
.idea
misc.xml 197B
workspace.xml 29KB
InterfaceOne.iml 511B
modules.xml 276B
case
demo_api.xlsx 10KB
test_api.py 1KB
__pycache__
test_api.cpython-36.pyc 1KB
venv
Lib
tcl8.6
init.tcl 24KB
site-packages
setuptools-28.8.0-py3.6.egg 454KB
setuptools.pth 31B
Scripts
unicodedata.pyd 875KB
tk86t.dll 1.48MB
easy_install-3.6.exe.manifest 651B
_multiprocessing.pyd 25KB
pip3.6.exe 64KB
easy_install-3.6-script.py 470B
pip.exe.manifest 638B
_testbuffer.pyd 41KB
_msi.pyd 33KB
_bz2.pyd 77KB
_asyncio.pyd 45KB
_testconsole.pyd 21KB
easy_install.exe.manifest 647B
_socket.pyd 62KB
easy_install-script.py 462B
activate 2KB
python36.dll 3.15MB
python3.dll 57KB
_lzma.pyd 180KB
tcl86t.dll 1.25MB
pip.exe 64KB
pythonw.exe 94KB
pip3.6-script.py 426B
_ssl.pyd 1.39MB
_testimportmultiple.pyd 19KB
_overlapped.pyd 34KB
Activate.ps1 1KB
easy_install-3.6.exe 64KB
winsound.pyd 24KB
_decimal.pyd 212KB
_hashlib.pyd 1.07MB
_ctypes.pyd 100KB
sqlite3.dll 860KB
pip3-script.py 422B
_testcapi.pyd 75KB
deactivate.bat 368B
pip3.exe 64KB
_ctypes_test.pyd 30KB
easy_install.exe 64KB
_elementtree.pyd 160KB
_distutils_findvs.pyd 22KB
pip-script.py 420B
_sqlite3.pyd 63KB
_testmultiphase.pyd 26KB
pip3.exe.manifest 639B
_tkinter.pyd 52KB
pyexpat.pyd 161KB
activate.bat 1KB
select.pyd 23KB
vcruntime140.dll 82KB
pip3.6.exe.manifest 641B
python.exe 96KB
pyvenv.cfg 82B
common
result.xlsx 5KB
HTMLTestRunner_cn.py 83KB
testreport.xlsx 5KB
debug_api.xlsx 9KB
HTMLTestRunner.py 25KB
readexcel.py 1KB
__pycache__
HTMLTestRunner_cn.cpython-36.pyc 77KB
base_api.cpython-36.pyc 2KB
readexcel.cpython-36.pyc 1KB
writeexcel.cpython-36.pyc 1KB
base_api.py 3KB
writeexcel.py 1KB
run_this.py 1KB
共 79 条
- 1
资源评论
- friend50872021-07-06不是我要找的,我找自动化集成禅道,可以直接提bug的
乐乐熊小妹
- 粉丝: 5
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- UE4仅k位移产生完美行走动作-UE4项目
- tensorflow-2.6.3-cp37-cp37m-manylinux2010-x86-64.whl
- tensorflow-2.6.2-cp39-cp39-win-amd64.whl
- tensorflow-2.6.2-cp39-cp39-manylinux2010-x86-64.whl
- 基于Python卷积神经网络人脸识别驾驶员疲劳检测与预警系统源码+使用说明+全部资料.zip
- BPNN-预测.rar
- 灾难分类数据集 PNG(12类 4.8K+ 张图像)
- java8和17的windows、linux版本
- MDK5.18版本,退出仿真不会有问题
- 预测-AE-1.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功