Skip to content

Commit

Permalink
fix add_time_report_to_email keyError issue (#8704)
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Horak <dahorak@redhat.com>
  • Loading branch information
dahorak authored Oct 18, 2023
1 parent a907a42 commit a5db2d5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion ocs_ci/framework/pytest_customization/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def pytest_sessionfinish(session, exitstatus):
# creating report of test cases with total time in ascending order
data = GV.TIMEREPORT_DICT
sorted_data = dict(
sorted(data.items(), key=lambda item: item[1]["total"], reverse=True)
sorted(data.items(), key=lambda item: item[1].get("total"), reverse=True)
)
try:
time_report_file = os.path.join(
Expand Down Expand Up @@ -151,6 +151,9 @@ def pytest_report_teststatus(report, config):
GV.TIMEREPORT_DICT[report.nodeid]["setup"] = round(report.duration, 2)
GV.TIMEREPORT_DICT[report.nodeid]["total"] = round(report.duration, 2)

if "total" not in GV.TIMEREPORT_DICT[report.nodeid]:
GV.TIMEREPORT_DICT[report.nodeid]["total"] = 0

if report.when == "call":
logger.info(
f"duration reported by {report.nodeid} immediately after test execution: {round(report.duration, 2)}"
Expand Down
2 changes: 1 addition & 1 deletion ocs_ci/utility/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4494,7 +4494,7 @@ def add_time_report_to_email(session, soup):
"""
data = GV.TIMEREPORT_DICT
sorted_data = dict(
sorted(data.items(), key=lambda item: item[1]["total"], reverse=True)
sorted(data.items(), key=lambda item: item[1].get("total", 0), reverse=True)
)

file_loader = FileSystemLoader(constants.HTML_REPORT_TEMPLATE_DIR)
Expand Down

0 comments on commit a5db2d5

Please sign in to comment.