##// END OF EJS Templates
Merge pull request #4678 from ivanov/console-display-text...
Min RK -
r13867:edb38312 merge
parent child Browse files
Show More
@@ -263,8 +263,12 b' class ZMQTerminalInteractiveShell(TerminalInteractiveShell):'
263 263 hook.finish_displayhook()
264 264
265 265 elif msg_type == 'display_data':
266 self.handle_rich_data(sub_msg["content"]["data"])
267
266 data = sub_msg["content"]["data"]
267 handled = self.handle_rich_data(data)
268 if not handled:
269 # if it was an image, we handled it by now
270 if 'text/plain' in data:
271 print(data['text/plain'])
268 272
269 273 _imagemime = {
270 274 'image/png': 'png',
@@ -276,7 +280,7 b' class ZMQTerminalInteractiveShell(TerminalInteractiveShell):'
276 280 for mime in self.mime_preference:
277 281 if mime in data and mime in self._imagemime:
278 282 self.handle_image(data, mime)
279 return
283 return True
280 284
281 285 def handle_image(self, data, mime):
282 286 handler = getattr(
@@ -13,14 +13,11 b' Authors:'
13 13 #-----------------------------------------------------------------------------
14 14
15 15 import sys
16 import time
17 16
18 import nose.tools as nt
19 17 from nose import SkipTest
20 18
21 19 import IPython.testing.tools as tt
22 20 from IPython.testing import decorators as dec
23 from IPython.utils import py3compat
24 21
25 22 #-----------------------------------------------------------------------------
26 23 # Tests
@@ -29,6 +26,42 b' from IPython.utils import py3compat'
29 26 @dec.skip_win32
30 27 def test_console_starts():
31 28 """test that `ipython console` starts a terminal"""
29 p, pexpect, t = start_console()
30 p.sendline('5')
31 idx = p.expect([r'Out\[\d+\]: 5', pexpect.EOF], timeout=t)
32 idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=t)
33 stop_console(p, pexpect, t)
34
35 def test_help_output():
36 """ipython console --help-all works"""
37 tt.help_all_output_test('console')
38
39
40 def test_display_text():
41 "Ensure display protocol plain/text key is supported"
42 # equivalent of:
43 #
44 # x = %lsmagic
45 # from IPython.display import display; display(x);
46 p, pexpect, t = start_console()
47 p.sendline('x = %lsmagic')
48 idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=t)
49 p.sendline('from IPython.display import display; display(x);')
50 p.expect([r'Available line magics:', pexpect.EOF], timeout=t)
51 stop_console(p, pexpect, t)
52
53 def stop_console(p, pexpect, t):
54 "Stop a running `ipython console` running via pexpect"
55 # send ctrl-D;ctrl-D to exit
56 p.sendeof()
57 p.sendeof()
58 p.expect([pexpect.EOF, pexpect.TIMEOUT], timeout=t)
59 if p.isalive():
60 p.terminate()
61
62
63 def start_console():
64 "Start `ipython console` using pexpect"
32 65 from IPython.external import pexpect
33 66
34 67 args = ['console', '--colors=NoColor']
@@ -47,17 +80,4 b' def test_console_starts():'
47 80 # timeout after one minute
48 81 t = 60
49 82 idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=t)
50 p.sendline('5')
51 idx = p.expect([r'Out\[\d+\]: 5', pexpect.EOF], timeout=t)
52 idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=t)
53 # send ctrl-D;ctrl-D to exit
54 p.sendeof()
55 p.sendeof()
56 p.expect([pexpect.EOF, pexpect.TIMEOUT], timeout=t)
57 if p.isalive():
58 p.terminate()
59
60 def test_help_output():
61 """ipython console --help-all works"""
62 tt.help_all_output_test('console')
63
83 return p, pexpect, t
General Comments 0
You need to be logged in to leave comments. Login now