使用python+HTMLTestRunner+unittest框架,单个执行接口记录日志成功,但执行run.py文件时为什么不能记录日志

把每个接口返回信息都使用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()
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值