diff --git a/reframe/frontend/runreport.py b/reframe/frontend/runreport.py index 5e981d2edd..a5f0d54f64 100644 --- a/reframe/frontend/runreport.py +++ b/reframe/frontend/runreport.py @@ -213,7 +213,7 @@ def junit_xml_report(json_report): # XSD schema does not like the exponential format and since # we do not want to impose a fixed width, we pass it to # `Decimal` to format it automatically. - 'time': str(decimal.Decimal(tc['time_total'])), + 'time': str(decimal.Decimal(tc['time_total'] or 0)), } ) if tc['result'] == 'failure': diff --git a/unittests/test_policies.py b/unittests/test_policies.py index 1ff0f7a546..0c4a0fb8de 100644 --- a/unittests/test_policies.py +++ b/unittests/test_policies.py @@ -237,6 +237,10 @@ def test_runall(make_runner, make_cases, common_exec_ctx, tmp_path): with open(report_file, 'w') as fp: jsonext.dump(report, fp) + # We explicitly set `time_total` to `None` in the last test case, in order + # to test the proper handling of `None`.` + report['runs'][0]['testcases'][-1]['time_total'] = None + # Validate the junit report xml_report = runreport.junit_xml_report(report) _validate_junit_report(xml_report)