From ebb001ec4e4a66ffa230b2bd97c69a638e56cc95 2017-06-09 23:24:37 From: Matthias Bussonnier Date: 2017-06-09 23:24:37 Subject: [PATCH] Merge pull request #10625 from kr1m/master Fix signature for IPython.core.display:Pretty #10595 --- 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('
')