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:
@@ -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}],
|
||||
|
Reference in New Issue
Block a user