01.第一种我们引用的 HTMLTestReportCN.py 如下代码
--coding=utf-8--
import unittest
import os, time
import HTMLTestReportCN
用例路径
case_path = ‘F:\python3\python_code\test_case_suite’
def AllTest():
‘’‘获取所有的测试模块’‘’
suite = unittest.TestLoader().discover(
start_dir=os.path.dirname(case_path),
pattern=‘case*.py’,
top_level_dir=None
)
return suite
def getNowTime():
‘’‘获取当前的时间’‘’
return time.strftime(‘%Y-%m-%d-%H-%M-%S’, time.localtime(time.time()))
def run():
fileName = os.path.join(‘F:\python3\report’,
getNowTime() + ‘report.html’)
fp = open(fileName,‘wb’)
runner = HTMLTestReportCN.HTMLTestRunner(
stream=fp,
title=u’项目测试环境单元测试报告’,
description=u’注:为减少时间人力成本,提高转测质量