标签:workspace ber 问题 png rip epo load bsp 代码块
Traceback (most recent call last): File "D:\Ddworkspace\workspace\DdScript\dmall-small-program\autoPyWxInterface\run_start_auto.py", line 39, in <module> runner.run(discover) File "D:\Ddworkspace\workspace\DdScript\dmall-small-program\autoPyWxInterface\common\HTMLTestReportCNs.py", line 549, in run self.generateReport(test, result) File "D:\Ddworkspace\workspace\DdScript\dmall-small-program\autoPyWxInterface\common\HTMLTestReportCNs.py", line 596, in generateReport report_attrs = self.getReportAttributes(result) File "D:\Ddworkspace\workspace\DdScript\dmall-small-program\autoPyWxInterface\common\HTMLTestReportCNs.py", line 584, in getReportAttributes self.passrate = str("%.2f%%" % (float(result.success_count) / float(result.success_count + result.failure_count + result.error_count) * 100)) ZeroDivisionError: float division by zero
2.1 result.success_count + result.failure_count + result.error_count等于0,也就是说成功case,失败case,错误case都为0
2.2 正常情况,只要我们代码没问题,这三个必有一个字段值大于0
3.1 result.success_count + result.failure_count + result.error_count这三种值均来自于result
3.2 追踪result最初入口
3.3 入口:runner.run(discover)
4.1 在runner.run(discover) 打断点
4.2 debug后,我们可以看到discover中内容
<unittest.suite.TestSuite tests=[<unittest.suite.TestSuite tests=[]>, <unittest.suite.TestSuite tests=[<unittest.suite.TestSuite tests=[]>, <unittest.suite.TestSuite tests=[]>]>, <unittest.suite.TestSuite tests=[]>, <unittest.suite.TestSuite tests=[]>, <unittest.suite.TestSuite tests=[]>]>
图
4.3 可以看到里面未检测到任何test开头的用例
4.5 所以我们就知道去哪里找问题了,对应的测试用例py文件中因为各种原因未运行test开头的这行代码
4.6 这里因为这个条件,所以不会进入if语句,所以没有运行if代码块中的内容(引起此问题的原因很多 ,可以根据上面方法进行排查)
5.1 将if条件中的not去掉即可
5.2 正确显示
Python3-接口自动化-10-记一次HTMLTestReportCNs.py中float division by zero排查
标签:workspace ber 问题 png rip epo load bsp 代码块
原文地址:https://www.cnblogs.com/chushujin/p/14229077.html