From bcdb55b3a0accae46f5ccdb3c002f8b08fe08770 2018-04-17 22:49:29 From: Matthew Seal Date: 2018-04-17 22:49:29 Subject: [PATCH] Added fix for display hook call output format --- diff --git a/IPython/core/displayhook.py b/IPython/core/displayhook.py index a236522..d6d3be2 100644 --- a/IPython/core/displayhook.py +++ b/IPython/core/displayhook.py @@ -317,4 +317,4 @@ class CapturingDisplayHook(object): if result is None: return format_dict, md_dict = self.shell.display_formatter.format(result) - self.outputs.append((format_dict, md_dict)) + self.outputs.append({ 'data': format_dict, 'metadata': md_dict }) diff --git a/IPython/core/tests/test_displayhook.py b/IPython/core/tests/test_displayhook.py index 7887f77..a00357b 100644 --- a/IPython/core/tests/test_displayhook.py +++ b/IPython/core/tests/test_displayhook.py @@ -101,3 +101,11 @@ def test_interactivehooks_ast_modes_semi_supress(): finally: ip.ast_node_interactivity = saved_mode + +def test_capture_display_hook_format(): + """Tests that the capture display hook conforms to the CapturedIO output format""" + hook = CapturingDisplayHook(ip) + hook({"foo": "bar"}) + captured = CapturedIO(sys.stdout, sys.stderr, hook.outputs) + # Should not raise with RichOutput transformation error + captured.outputs