# coding=utf-8
import HTMLTestRunner
import os
import unittest
import time
# 设置报告文件保存路径
report_path = os.path.dirname(os.path.abspath(".")) + '/test_reports/'
# 获取系统当前时间
now = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time()))
# 设置报告名称格式
html_file = report_path + now + "HTMLTemplate.html"
fp = open(html_file, "wb")
# 构建suite
# suite = unittest.TestSuite()
# suite.addTest(TestBaiduSearch('test_baidu_search'))
# suite.addTest(TestGetPageTitle('test_get_page_title'))
# # 通过makeSuite把整个class的测试case都加入套件中
# suite = unittest.TestSuite(unittest.makeSuite(TestBaiduSearch))
# 通过discover把整个package的所有测试case都加入套件中
suite = unittest.TestLoader().discover("testsuites")
if __name__ == '__main__':
# # 执行测试用例
# runner = unittest.TextTestRunner()
# 初始化一个HTMLTestRunner实例对象,用来生成报告
runner = HTMLTestRunner.HTMLTestRunner(stream=fp, title=u"某某项目测试报告", description=u"用例测试情况")
# 开始执行套件
runner.run(suite)
问题:当我运行这段程序的时候,提示报错:
<_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'>
Time Elapsed: 0:00:00.000047