From df77a784d7743182d75947c6f70ddd5d639a1deb 2013-12-12 05:56:07 From: Paul Ivanov Date: 2013-12-12 05:56:07 Subject: [PATCH] test for text/plain display handling in console --- diff --git a/IPython/terminal/console/tests/test_console.py b/IPython/terminal/console/tests/test_console.py index 09351a0..8711e08 100644 --- a/IPython/terminal/console/tests/test_console.py +++ b/IPython/terminal/console/tests/test_console.py @@ -61,3 +61,40 @@ def test_help_output(): """ipython console --help-all works""" tt.help_all_output_test('console') + +def test_display_text(): + "Ensure display protocol plain/text key is supported" + # equivalent of: + # + # x = %lsmagic + # from IPython.display import display; display(x); + + from IPython.external import pexpect + + args = ['console', '--colors=NoColor'] + # FIXME: remove workaround for 2.6 support + if sys.version_info[:2] > (2,6): + args = ['-m', 'IPython'] + args + cmd = sys.executable + else: + cmd = 'ipython' + + try: + p = pexpect.spawn(cmd, args=args) + except IOError: + raise SkipTest("Couldn't find command %s" % cmd) + + # timeout after one minute + t = 60 + idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=t) + p.sendline('x = %lsmagic') + idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=t) + p.sendline('from IPython.display import display; display(x);') + p.expect([r'Available line magics:', pexpect.EOF], timeout=t) + + # send ctrl-D;ctrl-D to exit + p.sendeof() + p.sendeof() + p.expect([pexpect.EOF, pexpect.TIMEOUT], timeout=t) + if p.isalive(): + p.terminate()