diff --git a/IPython/core/display.py b/IPython/core/display.py index 0569134..4f30566 100644 --- a/IPython/core/display.py +++ b/IPython/core/display.py @@ -672,8 +672,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 0dd684c..4ec26ad 100644 --- a/IPython/core/tests/test_display.py +++ b/IPython/core/tests/test_display.py @@ -162,6 +162,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('
')