TA的每日心情 | 擦汗 前天 09:07 |
---|
签到天数: 527 天 连续签到: 4 天 [LV.9]测试副司令
|
1测试积点
- 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
复制代码 请教高手怎么解决?原因是什么?
|
|