Hi Dean,

good timing! I actually noticed this issue last week and was going to tackle it soon.


On 13/01/2025 21:52, Dean Marx wrote:
@@ -324,13 +324,15 @@ def generate_pass_rate_dict(self, test_run_summary) -> 
dict[str, float]:
          Returns:
              A dictionary with the PASS/FAIL ratio of all test cases.
          """
-        return {
-            "PASS_RATE": (
-                float(test_run_summary[Result.PASS.name])
-                * 100
-                / sum(test_run_summary[result.name] for result in Result if 
result != Result.SKIP)
-            )
-        }
+        cases_not_skipped = sum(
+            test_run_summary[result.name] for result in Result if result != 
Result.SKIP
+        )
+        if cases_not_skipped == 0:
+            return {"PASS_RATE": 0.0}
+        else:
+            return {
+                "PASS_RATE": (float(test_run_summary[Result.PASS.name]) * 100 
/ cases_not_skipped)
+            }

The solution feels a bit overcomplicated, you can just throw a max(sum(..), 1), so:

    ran_tests = sum(test_run_summary[result.name] for result in Result
                    if result != Result.SKIP)
    return {
"PASS_RATE": test_run_summary[Result.PASS.name] * 100.0 / max(ran_tests, 1)
    }

also while you are at it, changing the 100 to 100.0 will spare us from writing a longer float(..) expression.

Reply via email to