From 59e55197f77f9eb83237a8b1ec09ce549a5c0dfc Mon Sep 17 00:00:00 2001 From: Marco Nenciarini Date: Fri, 25 Oct 2024 09:56:08 +0200 Subject: [PATCH] fix: do not round up percentages Signed-off-by: Marco Nenciarini --- summarize_test_results.py | 5 ++++- test_summary.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/summarize_test_results.py b/summarize_test_results.py index 21edfd6..059d72e 100644 --- a/summarize_test_results.py +++ b/summarize_test_results.py @@ -53,6 +53,7 @@ import argparse from datetime import datetime import json +import math import os import pathlib from prettytable import MARKDOWN @@ -628,7 +629,9 @@ def compute_thermometer_on_metric(summary, metric, embed=True): runs = summary[metric]["total"][bucket] success_percent = (1 - failures / runs) * 100 color = compute_semaphore(success_percent, embed) - output += f"- {color} - {bucket}: {round(success_percent, 1)}% success.\t" + output += ( + f"- {color} - {bucket}: {math.floor(success_percent*10)/10}% success.\t" + ) output += f"({failures} out of {runs} tests failed)\n" output += f"\n" return output diff --git a/test_summary.py b/test_summary.py index 5ad5f2e..e56a106 100644 --- a/test_summary.py +++ b/test_summary.py @@ -76,7 +76,7 @@ def test_compute_thermometer(self): self.assertEqual( thermometer, "Platforms thermometer:\n\n" - "- 🔴 - local: 66.7% success.\t(1 out of 3 tests failed)\n\n", + "- 🔴 - local: 66.6% success.\t(1 out of 3 tests failed)\n\n", ) thermometerPlaintext = summarize_test_results.compute_thermometer_on_metric( @@ -86,7 +86,7 @@ def test_compute_thermometer(self): self.assertEqual( thermometerPlaintext, "Platforms thermometer:\n\n" - "- :red_circle: - local: 66.7% success.\t(1 out of 3 tests failed)\n\n", + "- :red_circle: - local: 66.6% success.\t(1 out of 3 tests failed)\n\n", ) def test_compute_systematic_failures(self):