Skip to content

Commit

Permalink
fix: do not round up percentages
Browse files Browse the repository at this point in the history
Signed-off-by: Marco Nenciarini <[email protected]>
  • Loading branch information
mnencia committed Oct 25, 2024
1 parent 2a6ea8d commit 59e5519
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion summarize_test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import argparse
from datetime import datetime
import json
import math
import os
import pathlib
from prettytable import MARKDOWN
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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):
Expand Down

0 comments on commit 59e5519

Please sign in to comment.