Show More
@@ -263,8 +263,12 b' class ZMQTerminalInteractiveShell(TerminalInteractiveShell):' | |||||
263 | hook.finish_displayhook() |
|
263 | hook.finish_displayhook() | |
264 |
|
264 | |||
265 | elif msg_type == 'display_data': |
|
265 | elif msg_type == 'display_data': | |
266 |
|
|
266 | data = sub_msg["content"]["data"] | |
267 |
|
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 | _imagemime = { |
|
273 | _imagemime = { | |
270 | 'image/png': 'png', |
|
274 | 'image/png': 'png', | |
@@ -276,7 +280,7 b' class ZMQTerminalInteractiveShell(TerminalInteractiveShell):' | |||||
276 | for mime in self.mime_preference: |
|
280 | for mime in self.mime_preference: | |
277 | if mime in data and mime in self._imagemime: |
|
281 | if mime in data and mime in self._imagemime: | |
278 | self.handle_image(data, mime) |
|
282 | self.handle_image(data, mime) | |
279 | return |
|
283 | return True | |
280 |
|
284 | |||
281 | def handle_image(self, data, mime): |
|
285 | def handle_image(self, data, mime): | |
282 | handler = getattr( |
|
286 | handler = getattr( |
@@ -13,14 +13,11 b' Authors:' | |||||
13 | #----------------------------------------------------------------------------- |
|
13 | #----------------------------------------------------------------------------- | |
14 |
|
14 | |||
15 | import sys |
|
15 | import sys | |
16 | import time |
|
|||
17 |
|
16 | |||
18 | import nose.tools as nt |
|
|||
19 | from nose import SkipTest |
|
17 | from nose import SkipTest | |
20 |
|
18 | |||
21 | import IPython.testing.tools as tt |
|
19 | import IPython.testing.tools as tt | |
22 | from IPython.testing import decorators as dec |
|
20 | from IPython.testing import decorators as dec | |
23 | from IPython.utils import py3compat |
|
|||
24 |
|
21 | |||
25 | #----------------------------------------------------------------------------- |
|
22 | #----------------------------------------------------------------------------- | |
26 | # Tests |
|
23 | # Tests | |
@@ -29,6 +26,42 b' from IPython.utils import py3compat' | |||||
29 | @dec.skip_win32 |
|
26 | @dec.skip_win32 | |
30 | def test_console_starts(): |
|
27 | def test_console_starts(): | |
31 | """test that `ipython console` starts a terminal""" |
|
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 | from IPython.external import pexpect |
|
65 | from IPython.external import pexpect | |
33 |
|
66 | |||
34 | args = ['console', '--colors=NoColor'] |
|
67 | args = ['console', '--colors=NoColor'] | |
@@ -47,17 +80,4 b' def test_console_starts():' | |||||
47 | # timeout after one minute |
|
80 | # timeout after one minute | |
48 | t = 60 |
|
81 | t = 60 | |
49 | idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=t) |
|
82 | idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=t) | |
50 | p.sendline('5') |
|
83 | return p, pexpect, t | |
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 |
|
General Comments 0
You need to be logged in to leave comments.
Login now