fix(unittest): handle error outside of file

If an error occurs outside of the test file, there is no frame to match
an error to. This can happen for example when required arguments are not
passed to the test.
This commit is contained in:
Rónán Carrigan
2023-02-16 09:19:15 +00:00
parent 1c06dfac57
commit 4398ba1063

View File

@@ -72,11 +72,10 @@ class UnittestNeotestAdapter(NeotestAdapter):
if case_id in errs:
trace = errs[case_id][2]
summary = traceback.extract_tb(trace)
error_line = next(
frame.lineno - 1
for frame in reversed(summary)
if frame.filename == case_file
)
for frame in reversed(summary):
if frame.filename == case_file:
error_line = frame.lineno - 1
break
results[case_id] = {
"status": NeotestResultStatus.FAILED,
"errors": [{"message": message, "line": error_line}],