diff --git a/pyinstrument/magic/magic.py b/pyinstrument/magic/magic.py index 7ed34a25..2689cd16 100644 --- a/pyinstrument/magic/magic.py +++ b/pyinstrument/magic/magic.py @@ -268,7 +268,7 @@ def _silent_exception_handler(self, etype, value, tb, tb_offset=None): ) text_config = compute_render_options( - args, renderer_class=HTMLRenderer, unicode_support=True, color_support=True + args, renderer_class=ConsoleRenderer, unicode_support=True, color_support=True ) html_renderer = renderers.HTMLRenderer(show_all=args.show_all, timeline=args.timeline) diff --git a/test/test_ipython_magic.py b/test/test_ipython_magic.py index a3896b51..20ab782a 100644 --- a/test/test_ipython_magic.py +++ b/test/test_ipython_magic.py @@ -6,6 +6,8 @@ import pytest +from .util import strip_ansi + # note: IPython should be imported within each test. Importing it in our tests # seems to cause problems with subsequent tests. @@ -49,10 +51,11 @@ def test_magics(ip): assert "function_a" in output.data["text/html"] assert " NoReturn: raise AssertionError(f"Invalid value: {x!r}") +def strip_ansi(value: str) -> str: + return re.sub(r"\x1b\[[0-9;]*m", "", value) + + def do_nothing(): pass