Skip to content

Commit f5b290b

Browse files
committed
Fixed issue when there are 0 tests to get the format color
1 parent 5128c09 commit f5b290b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

generate_xlsx_report.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,13 @@ def get_format_color(self, index: int, num_elements: int):
476476
Return the corresponding color format depending on the ratio of
477477
passed_tests/total_tests
478478
"""
479+
# this might only happen for supported tests when the total supported
480+
# scenarios is 0
481+
if num_elements == 0:
482+
return self.__formats['result_red']
483+
479484
ratio = index / num_elements
485+
480486
if ratio < 0.25:
481487
return self.__formats['result_red']
482488
elif ratio < 0.5:
@@ -488,7 +494,7 @@ def get_format_color(self, index: int, num_elements: int):
488494
else: # ratio == 1
489495
return self.__formats['result_green']
490496

491-
def get_format_color_bool(self, status: TestStatus):
497+
def get_format_color_test_status(self, status: TestStatus):
492498
"""
493499
Get the corresponding color format depending on 'status'.
494500
Green if status is PASSED, Red if FAILED, Yellow if UNSUPPORTED
@@ -721,7 +727,7 @@ def add_product_table(self,
721727
process_row,
722728
process_column,
723729
str_result,
724-
self.get_format_color_bool(element.get_status()))
730+
self.get_format_color_test_status(element.get_status()))
725731
return (current_row, current_column)
726732

727733
def add_data_summary_worksheet(self,

0 commit comments

Comments
 (0)