diff --git a/ocs_ci/framework/pytest_customization/reports.py b/ocs_ci/framework/pytest_customization/reports.py index fc9fb8d8d58..b6bce222181 100644 --- a/ocs_ci/framework/pytest_customization/reports.py +++ b/ocs_ci/framework/pytest_customization/reports.py @@ -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( @@ -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)}" diff --git a/ocs_ci/utility/utils.py b/ocs_ci/utility/utils.py index 84cf1d0604b..b8c1a1dbfdd 100644 --- a/ocs_ci/utility/utils.py +++ b/ocs_ci/utility/utils.py @@ -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)