feat(pytest): strip ansi codes from errors
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from io import StringIO
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
from typing import Callable, Dict, List, Optional, Union
|
||||
|
||||
import pytest
|
||||
@@ -10,6 +11,7 @@ from _pytest.fixtures import FixtureLookupErrorRepr
|
||||
|
||||
from .base import NeotestAdapter, NeotestError, NeotestResult, NeotestResultStatus
|
||||
|
||||
ANSI_ESCAPE = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])')
|
||||
|
||||
class PytestNeotestAdapter(NeotestAdapter):
|
||||
def __init__(self, emit_parameterized_ids: bool):
|
||||
@@ -131,7 +133,7 @@ class NeotestResultCollector:
|
||||
errors.append({"message": msg_prefix + exc_repr, "line": None})
|
||||
# Test failed internally
|
||||
elif isinstance(exc_repr, ExceptionRepr):
|
||||
error_message = exc_repr.reprcrash.message # type: ignore
|
||||
error_message = ANSI_ESCAPE.sub('', exc_repr.reprcrash.message) # type: ignore
|
||||
error_line = None
|
||||
for traceback_entry in reversed(call.excinfo.traceback):
|
||||
if str(traceback_entry.path) == abs_path:
|
||||
|
||||
Reference in New Issue
Block a user