生成测试报告的文件,运行时报错,但debug执行正常
listaa = "D:\\python\\cover"def createsuite1():
testunit1=unittest.TestSuite()
discover=unittest.defaultTestLoader.discover(listaa,pattern='cover_*.py',top_level_dir=None)
# print(discover)
for test_suite in discover:
for test_case in test_suite:
testunit1.addTests(test_case)
print(testunit1)
return testunit1
now = time.strftime("%Y-%m-%d %H_%M_%S",time.localtime())
filename="D:\\testpython\\cover\\html\\"+now+"_result.html"
fp=open(filename,'wb')
runner=HTMLTestRunner.HTMLTestRunner(
stream=fp,
title=u'搜索功能测试报告',
description=u'用例执行情况:')
runner.run(createsuite1())
# 关闭文件流,不关的话生成的报告是空的
fp.close()
这个文件我在pycharm里debug执行正确,但运行时报错:
Traceback (most recent call last):
File "D:/testpython/cover/html.py", line 31, in <module>
runner.run(createsuite1())
File "D:/testpython/cover/html.py", line 18, in createsuite1
testunit1.addTests(test_case)
File "C:\Program Files\Python36\lib\unittest\suite.py", line 57, in addTests
for test in tests:
TypeError: '_FailedTest' object is not iterable请教高手怎么解决?原因是什么?
参考看下呢:https://blog.csdn.net/weixin_44316575/article/details/89258034 加一个时间延时 等待1秒 来占沙发 了解
页:
[1]