From 897941a41ed6b9feee536b9d877185d06c64c6fa 2014-06-26 20:21:29 From: MinRK Date: 2014-06-26 20:21:29 Subject: [PATCH] strip ANSI colors from tracebacks when normalizing outputs --- diff --git a/IPython/nbconvert/preprocessors/tests/test_execute.py b/IPython/nbconvert/preprocessors/tests/test_execute.py index 649c94d..773d918 100644 --- a/IPython/nbconvert/preprocessors/tests/test_execute.py +++ b/IPython/nbconvert/preprocessors/tests/test_execute.py @@ -5,9 +5,6 @@ Module with tests for the execute preprocessor. # Copyright (c) IPython Development Team. # Distributed under the terms of the Modified BSD License. -#----------------------------------------------------------------------------- -# Imports -#----------------------------------------------------------------------------- import copy import os import re @@ -17,10 +14,11 @@ from IPython.nbformat import current as nbformat from .base import PreprocessorTestsBase from ..execute import ExecutePreprocessor +from IPython.nbconvert.filters import strip_ansi + + +addr_pat = re.compile(r'0x[0-9a-f]{7,9}') -#----------------------------------------------------------------------------- -# Class -#----------------------------------------------------------------------------- class TestExecute(PreprocessorTestsBase): """Contains test functions for execute.py""" @@ -34,9 +32,15 @@ class TestExecute(PreprocessorTestsBase): if 'metadata' in cell: del cell['metadata'] if 'text' in cell: - cell['text'] = re.sub('0x[0-9a-f]{7,9}', '', cell['text']) + cell['text'] = re.sub(addr_pat, '', cell['text']) if 'svg' in cell: del cell['text'] + if 'traceback' in cell: + tb = [] + for line in cell['traceback']: + tb.append(strip_ansi(line)) + cell['traceback'] = tb + return cell