把每个接口返回信息都使用logging记录了日志,单个执行接口记录日志成功,但执行run.py文件时,却不记录日志,请大神解惑!!!
以下是run.py文件
def creatsuite(): #创建测试用例集
testsuite = unittest.TestSuite()
discover = unittest.defaultTestLoader.discover(
start_dir=case_path,
pattern="test*.py",
top_level_dir=None,
)
for allcase in discover:
for case in allcase:
testsuite.addTests(case)
print(testsuite)
return testsuite
if __name__ == "__main__":
# 1、按照一定格式获取当前时间
now = time.strftime('%Y-%m-%d_%H-%M-%S',time.localtime(time.time()))
# 2、html报告文件路径
filename = os.path.join(report_path,now+"result.html")
print("测试报告路径==========================>",filename)
# 3、打开一个文件,将result写入此file中
fp = open(filename,'wb')
runner = HTMLTestRunner.HTMLTestRunner(stream=fp,
title="chen测试用例",
description="测试情况,如下:",
verbosity=2)
# 4、调用add_case函数返回值
runner.run(creatsuite())
fp.close()