当前第2页 返回上一页
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | import os
import time
def findTestWithPath():
current_dir = os.getcwd()
folderName = os.listdir(current_dir)
TestSuit = [suite for suite in folderName if not suite.find( "TestSuit" )]
testfile = []
withPathFile = []
for suite in TestSuit:
testfile = testfile + os.listdir( ".\\" + suite)
for withPath in testfile:
withPath = current_dir + "\\"+suite+" \\" + withPath
withPathFile.append(withPath)
del testfile
withPathFile = [name for name in withPathFile if not "pyc" in name]
print withPathFile
return withPathFile
def codeCoverage():
now = time.strftime( "%Y%m%d%H%M" )
htmlReport = os.getcwd() + "\\"+" CoverageReport"
htmlCmd = "coverage html -d " + htmlReport + "\\" + now
for pyfile in findTestWithPath():
runPyCmd = "coverage run " + pyfile
if os.path.exists(htmlReport) :
os.system(runPyCmd)
os.system(htmlCmd)
else :
os.mkdir(htmlReport)
os.system(runPyCmd)
os.system(htmlCmd)
if __name__ = = "__main__" :
codeCoverage()
|
运行结果图:

相关推荐:
关于phpunit与Selenium取coverage的配备(原创)
以上就是unittest+coverage单元测试代码覆盖操作实例详解_python的详细内容,更多文章请关注木庄网络博客!!
返回前面的内容
相关阅读 >>
Python的gil是什么?Python中gil的介绍
Python队列的定义与使用方法实例详解
十分钟利用Python制作属于你自己的个性logo
Python如何调用dll库
pandas妙招之 dataframe基础运算以及空值填充
啥是佩奇,Python 告诉你!
Python--堡垒机的介绍
pytho中字典操作方法介绍(代码示例)
什么是Python解释器
Python的库是什么意思
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » unittest+coverage单元测试代码覆盖操作实例详解_python