使用HTMLTestRunner时出现了以下问题:

self.stream.write(output.encode(‘utf8’))
  ValueError: write to closed file

python生成测试报告HTMLTestRunner时报错ValueError: write to closed file的解决办法
原因是写入已经被关闭的文件导致报错,因为with open是自动保存的。

解决办法一:

runner必须同样在with open下进行:
python生成测试报告HTMLTestRunner时报错ValueError: write to closed file的解决办法
解决办法二:

不使用with open,直接使用open方法:

python生成测试报告HTMLTestRunner时报错ValueError: write to closed file的解决办法
看完点赞 ~养成好习惯,以上内容希望对你有帮助,如果对软件测试、接口测试、自动化测试、面试经验交流感兴趣可以加入我们。642830685,免费领取最新软件测试大厂面试资料和Python自动化、接口、框架搭建学习资料!技术大牛解惑答疑,同行一起交流。

相关文章: