From 717478ef4d9a0c0e04ee22b8cb227af766cd27d1 2017-05-31 02:58:05 From: ryan thielke Date: 2017-05-31 02:58:05 Subject: [PATCH] Fix signature for IPython.core.display:Pretty #10595 --- diff --git a/IPython/core/display.py b/IPython/core/display.py index 96015de..4ccc073 100644 --- a/IPython/core/display.py +++ b/IPython/core/display.py @@ -649,8 +649,8 @@ class TextDisplayObject(DisplayObject): class Pretty(TextDisplayObject): - def _repr_pretty_(self): - return self.data + def _repr_pretty_(self, pp, cycle): + return pp.text(self.data) class HTML(TextDisplayObject): diff --git a/IPython/core/tests/test_display.py b/IPython/core/tests/test_display.py index ac716ee..c587847 100644 --- a/IPython/core/tests/test_display.py +++ b/IPython/core/tests/test_display.py @@ -160,6 +160,13 @@ def test_display_available(): with AssertNotPrints('NameError'): ip.run_cell('display') +def test_textdisplayobj_pretty_repr(): + p = display.Pretty("This is a simple test") + nt.assert_equal(repr(p), '') + nt.assert_equal(p.data, 'This is a simple test') + + p._show_mem_addr = True + nt.assert_equal(repr(p), object.__repr__(p)) def test_displayobject_repr(): h = display.HTML('
')