diff --git a/IPython/core/display.py b/IPython/core/display.py index 76281b1..84c18e5 100644 --- a/IPython/core/display.py +++ b/IPython/core/display.py @@ -667,7 +667,19 @@ class Pretty(TextDisplayObject): class HTML(TextDisplayObject): def __init__(self, data=None, url=None, filename=None, metadata=None): - if data and data.startswith("") + + if warn(): warnings.warn("Consider using IPython.display.IFrame instead") super(HTML, self).__init__(data=data, url=url, filename=filename, metadata=metadata) diff --git a/IPython/core/tests/test_display.py b/IPython/core/tests/test_display.py index 24cdc03..1fed511 100644 --- a/IPython/core/tests/test_display.py +++ b/IPython/core/tests/test_display.py @@ -197,6 +197,9 @@ def test_displayobject_repr(): @mock.patch('warnings.warn') def test_encourage_iframe_over_html(m_warn): + display.HTML() + m_warn.assert_not_called() + display.HTML('
') m_warn.assert_not_called() @@ -206,6 +209,10 @@ def test_encourage_iframe_over_html(m_warn): display.HTML('') m_warn.assert_called_with('Consider using IPython.display.IFrame instead') + m_warn.reset_mock() + display.HTML('') + m_warn.assert_called_with('Consider using IPython.display.IFrame instead') + def test_progress(): p = display.ProgressBar(10) nt.assert_in('0/10',repr(p))