##// END OF EJS Templates
update kernel_info_reply test
Min RK -
Show More
@@ -1,429 +1,432 b''
1 """Test suite for our zeromq-based message specification."""
1 """Test suite for our zeromq-based message specification."""
2
2
3 # Copyright (c) IPython Development Team.
3 # Copyright (c) IPython Development Team.
4 # Distributed under the terms of the Modified BSD License.
4 # Distributed under the terms of the Modified BSD License.
5
5
6 import re
6 import re
7 import sys
7 from distutils.version import LooseVersion as V
8 from distutils.version import LooseVersion as V
8 from subprocess import PIPE
9 try:
9 try:
10 from queue import Empty # Py 3
10 from queue import Empty # Py 3
11 except ImportError:
11 except ImportError:
12 from Queue import Empty # Py 2
12 from Queue import Empty # Py 2
13
13
14 import nose.tools as nt
14 import nose.tools as nt
15
15
16 from IPython.kernel import KernelManager
17
18 from IPython.utils.traitlets import (
16 from IPython.utils.traitlets import (
19 HasTraits, TraitError, Bool, Unicode, Dict, Integer, List, Enum, Any,
17 HasTraits, TraitError, Bool, Unicode, Dict, Integer, List, Enum,
20 )
18 )
21 from IPython.utils.py3compat import string_types, iteritems
19 from IPython.utils.py3compat import string_types, iteritems
22
20
23 from .utils import TIMEOUT, start_global_kernel, flush_channels, execute
21 from .utils import TIMEOUT, start_global_kernel, flush_channels, execute
24
22
25 #-----------------------------------------------------------------------------
23 #-----------------------------------------------------------------------------
26 # Globals
24 # Globals
27 #-----------------------------------------------------------------------------
25 #-----------------------------------------------------------------------------
28 KC = None
26 KC = None
29
27
30 def setup():
28 def setup():
31 global KC
29 global KC
32 KC = start_global_kernel()
30 KC = start_global_kernel()
33
31
34 #-----------------------------------------------------------------------------
32 #-----------------------------------------------------------------------------
35 # Message Spec References
33 # Message Spec References
36 #-----------------------------------------------------------------------------
34 #-----------------------------------------------------------------------------
37
35
38 class Reference(HasTraits):
36 class Reference(HasTraits):
39
37
40 """
38 """
41 Base class for message spec specification testing.
39 Base class for message spec specification testing.
42
40
43 This class is the core of the message specification test. The
41 This class is the core of the message specification test. The
44 idea is that child classes implement trait attributes for each
42 idea is that child classes implement trait attributes for each
45 message keys, so that message keys can be tested against these
43 message keys, so that message keys can be tested against these
46 traits using :meth:`check` method.
44 traits using :meth:`check` method.
47
45
48 """
46 """
49
47
50 def check(self, d):
48 def check(self, d):
51 """validate a dict against our traits"""
49 """validate a dict against our traits"""
52 for key in self.trait_names():
50 for key in self.trait_names():
53 nt.assert_in(key, d)
51 nt.assert_in(key, d)
54 # FIXME: always allow None, probably not a good idea
52 # FIXME: always allow None, probably not a good idea
55 if d[key] is None:
53 if d[key] is None:
56 continue
54 continue
57 try:
55 try:
58 setattr(self, key, d[key])
56 setattr(self, key, d[key])
59 except TraitError as e:
57 except TraitError as e:
60 assert False, str(e)
58 assert False, str(e)
61
59
62
60
63 class Version(Unicode):
61 class Version(Unicode):
64 def __init__(self, *args, **kwargs):
62 def __init__(self, *args, **kwargs):
65 self.min = kwargs.pop('min', None)
63 self.min = kwargs.pop('min', None)
66 self.max = kwargs.pop('max', None)
64 self.max = kwargs.pop('max', None)
67 kwargs['default_value'] = self.min
65 kwargs['default_value'] = self.min
68 super(Version, self).__init__(*args, **kwargs)
66 super(Version, self).__init__(*args, **kwargs)
69
67
70 def validate(self, obj, value):
68 def validate(self, obj, value):
71 if self.min and V(value) < V(self.min):
69 if self.min and V(value) < V(self.min):
72 raise TraitError("bad version: %s < %s" % (value, self.min))
70 raise TraitError("bad version: %s < %s" % (value, self.min))
73 if self.max and (V(value) > V(self.max)):
71 if self.max and (V(value) > V(self.max)):
74 raise TraitError("bad version: %s > %s" % (value, self.max))
72 raise TraitError("bad version: %s > %s" % (value, self.max))
75
73
76
74
77 class RMessage(Reference):
75 class RMessage(Reference):
78 msg_id = Unicode()
76 msg_id = Unicode()
79 msg_type = Unicode()
77 msg_type = Unicode()
80 header = Dict()
78 header = Dict()
81 parent_header = Dict()
79 parent_header = Dict()
82 content = Dict()
80 content = Dict()
83
81
84 def check(self, d):
82 def check(self, d):
85 super(RMessage, self).check(d)
83 super(RMessage, self).check(d)
86 RHeader().check(self.header)
84 RHeader().check(self.header)
87 if self.parent_header:
85 if self.parent_header:
88 RHeader().check(self.parent_header)
86 RHeader().check(self.parent_header)
89
87
90 class RHeader(Reference):
88 class RHeader(Reference):
91 msg_id = Unicode()
89 msg_id = Unicode()
92 msg_type = Unicode()
90 msg_type = Unicode()
93 session = Unicode()
91 session = Unicode()
94 username = Unicode()
92 username = Unicode()
95 version = Version(min='5.0')
93 version = Version(min='5.0')
96
94
97 mime_pat = re.compile(r'^[\w\-\+\.]+/[\w\-\+\.]+$')
95 mime_pat = re.compile(r'^[\w\-\+\.]+/[\w\-\+\.]+$')
98
96
99 class MimeBundle(Reference):
97 class MimeBundle(Reference):
100 metadata = Dict()
98 metadata = Dict()
101 data = Dict()
99 data = Dict()
102 def _data_changed(self, name, old, new):
100 def _data_changed(self, name, old, new):
103 for k,v in iteritems(new):
101 for k,v in iteritems(new):
104 assert mime_pat.match(k)
102 assert mime_pat.match(k)
105 nt.assert_is_instance(v, string_types)
103 nt.assert_is_instance(v, string_types)
106
104
107 # shell replies
105 # shell replies
108
106
109 class ExecuteReply(Reference):
107 class ExecuteReply(Reference):
110 execution_count = Integer()
108 execution_count = Integer()
111 status = Enum((u'ok', u'error'))
109 status = Enum((u'ok', u'error'))
112
110
113 def check(self, d):
111 def check(self, d):
114 Reference.check(self, d)
112 Reference.check(self, d)
115 if d['status'] == 'ok':
113 if d['status'] == 'ok':
116 ExecuteReplyOkay().check(d)
114 ExecuteReplyOkay().check(d)
117 elif d['status'] == 'error':
115 elif d['status'] == 'error':
118 ExecuteReplyError().check(d)
116 ExecuteReplyError().check(d)
119
117
120
118
121 class ExecuteReplyOkay(Reference):
119 class ExecuteReplyOkay(Reference):
122 payload = List(Dict)
120 payload = List(Dict)
123 user_expressions = Dict()
121 user_expressions = Dict()
124
122
125
123
126 class ExecuteReplyError(Reference):
124 class ExecuteReplyError(Reference):
127 ename = Unicode()
125 ename = Unicode()
128 evalue = Unicode()
126 evalue = Unicode()
129 traceback = List(Unicode)
127 traceback = List(Unicode)
130
128
131
129
132 class InspectReply(MimeBundle):
130 class InspectReply(MimeBundle):
133 found = Bool()
131 found = Bool()
134
132
135
133
136 class ArgSpec(Reference):
134 class ArgSpec(Reference):
137 args = List(Unicode)
135 args = List(Unicode)
138 varargs = Unicode()
136 varargs = Unicode()
139 varkw = Unicode()
137 varkw = Unicode()
140 defaults = List()
138 defaults = List()
141
139
142
140
143 class Status(Reference):
141 class Status(Reference):
144 execution_state = Enum((u'busy', u'idle', u'starting'))
142 execution_state = Enum((u'busy', u'idle', u'starting'))
145
143
146
144
147 class CompleteReply(Reference):
145 class CompleteReply(Reference):
148 matches = List(Unicode)
146 matches = List(Unicode)
149 cursor_start = Integer()
147 cursor_start = Integer()
150 cursor_end = Integer()
148 cursor_end = Integer()
151 status = Unicode()
149 status = Unicode()
152
150
151 class LanguageInfo(Reference):
152 name = Unicode('python')
153 version = Unicode(sys.version.split()[0])
153
154
154 class KernelInfoReply(Reference):
155 class KernelInfoReply(Reference):
155 protocol_version = Version(min='5.0')
156 protocol_version = Version(min='5.0')
156 implementation = Unicode('ipython')
157 implementation = Unicode('ipython')
157 implementation_version = Version(min='2.1')
158 implementation_version = Version(min='2.1')
158 language_version = Version(min='2.7')
159 language = Unicode('python')
160 language_info = Dict()
159 language_info = Dict()
161 banner = Unicode()
160 banner = Unicode()
161
162 def check(self, d):
163 Reference.check(self, d)
164 LanguageInfo().check(d['language_info'])
162
165
163
166
164 class IsCompleteReply(Reference):
167 class IsCompleteReply(Reference):
165 status = Enum((u'complete', u'incomplete', u'invalid', u'unknown'))
168 status = Enum((u'complete', u'incomplete', u'invalid', u'unknown'))
166
169
167 def check(self, d):
170 def check(self, d):
168 Reference.check(self, d)
171 Reference.check(self, d)
169 if d['status'] == 'incomplete':
172 if d['status'] == 'incomplete':
170 IsCompleteReplyIncomplete().check(d)
173 IsCompleteReplyIncomplete().check(d)
171
174
172 class IsCompleteReplyIncomplete(Reference):
175 class IsCompleteReplyIncomplete(Reference):
173 indent = Unicode()
176 indent = Unicode()
174
177
175
178
176 # IOPub messages
179 # IOPub messages
177
180
178 class ExecuteInput(Reference):
181 class ExecuteInput(Reference):
179 code = Unicode()
182 code = Unicode()
180 execution_count = Integer()
183 execution_count = Integer()
181
184
182
185
183 Error = ExecuteReplyError
186 Error = ExecuteReplyError
184
187
185
188
186 class Stream(Reference):
189 class Stream(Reference):
187 name = Enum((u'stdout', u'stderr'))
190 name = Enum((u'stdout', u'stderr'))
188 text = Unicode()
191 text = Unicode()
189
192
190
193
191 class DisplayData(MimeBundle):
194 class DisplayData(MimeBundle):
192 pass
195 pass
193
196
194
197
195 class ExecuteResult(MimeBundle):
198 class ExecuteResult(MimeBundle):
196 execution_count = Integer()
199 execution_count = Integer()
197
200
198
201
199 references = {
202 references = {
200 'execute_reply' : ExecuteReply(),
203 'execute_reply' : ExecuteReply(),
201 'inspect_reply' : InspectReply(),
204 'inspect_reply' : InspectReply(),
202 'status' : Status(),
205 'status' : Status(),
203 'complete_reply' : CompleteReply(),
206 'complete_reply' : CompleteReply(),
204 'kernel_info_reply': KernelInfoReply(),
207 'kernel_info_reply': KernelInfoReply(),
205 'is_complete_reply': IsCompleteReply(),
208 'is_complete_reply': IsCompleteReply(),
206 'execute_input' : ExecuteInput(),
209 'execute_input' : ExecuteInput(),
207 'execute_result' : ExecuteResult(),
210 'execute_result' : ExecuteResult(),
208 'error' : Error(),
211 'error' : Error(),
209 'stream' : Stream(),
212 'stream' : Stream(),
210 'display_data' : DisplayData(),
213 'display_data' : DisplayData(),
211 'header' : RHeader(),
214 'header' : RHeader(),
212 }
215 }
213 """
216 """
214 Specifications of `content` part of the reply messages.
217 Specifications of `content` part of the reply messages.
215 """
218 """
216
219
217
220
218 def validate_message(msg, msg_type=None, parent=None):
221 def validate_message(msg, msg_type=None, parent=None):
219 """validate a message
222 """validate a message
220
223
221 This is a generator, and must be iterated through to actually
224 This is a generator, and must be iterated through to actually
222 trigger each test.
225 trigger each test.
223
226
224 If msg_type and/or parent are given, the msg_type and/or parent msg_id
227 If msg_type and/or parent are given, the msg_type and/or parent msg_id
225 are compared with the given values.
228 are compared with the given values.
226 """
229 """
227 RMessage().check(msg)
230 RMessage().check(msg)
228 if msg_type:
231 if msg_type:
229 nt.assert_equal(msg['msg_type'], msg_type)
232 nt.assert_equal(msg['msg_type'], msg_type)
230 if parent:
233 if parent:
231 nt.assert_equal(msg['parent_header']['msg_id'], parent)
234 nt.assert_equal(msg['parent_header']['msg_id'], parent)
232 content = msg['content']
235 content = msg['content']
233 ref = references[msg['msg_type']]
236 ref = references[msg['msg_type']]
234 ref.check(content)
237 ref.check(content)
235
238
236
239
237 #-----------------------------------------------------------------------------
240 #-----------------------------------------------------------------------------
238 # Tests
241 # Tests
239 #-----------------------------------------------------------------------------
242 #-----------------------------------------------------------------------------
240
243
241 # Shell channel
244 # Shell channel
242
245
243 def test_execute():
246 def test_execute():
244 flush_channels()
247 flush_channels()
245
248
246 msg_id = KC.execute(code='x=1')
249 msg_id = KC.execute(code='x=1')
247 reply = KC.get_shell_msg(timeout=TIMEOUT)
250 reply = KC.get_shell_msg(timeout=TIMEOUT)
248 validate_message(reply, 'execute_reply', msg_id)
251 validate_message(reply, 'execute_reply', msg_id)
249
252
250
253
251 def test_execute_silent():
254 def test_execute_silent():
252 flush_channels()
255 flush_channels()
253 msg_id, reply = execute(code='x=1', silent=True)
256 msg_id, reply = execute(code='x=1', silent=True)
254
257
255 # flush status=idle
258 # flush status=idle
256 status = KC.iopub_channel.get_msg(timeout=TIMEOUT)
259 status = KC.iopub_channel.get_msg(timeout=TIMEOUT)
257 validate_message(status, 'status', msg_id)
260 validate_message(status, 'status', msg_id)
258 nt.assert_equal(status['content']['execution_state'], 'idle')
261 nt.assert_equal(status['content']['execution_state'], 'idle')
259
262
260 nt.assert_raises(Empty, KC.iopub_channel.get_msg, timeout=0.1)
263 nt.assert_raises(Empty, KC.iopub_channel.get_msg, timeout=0.1)
261 count = reply['execution_count']
264 count = reply['execution_count']
262
265
263 msg_id, reply = execute(code='x=2', silent=True)
266 msg_id, reply = execute(code='x=2', silent=True)
264
267
265 # flush status=idle
268 # flush status=idle
266 status = KC.iopub_channel.get_msg(timeout=TIMEOUT)
269 status = KC.iopub_channel.get_msg(timeout=TIMEOUT)
267 validate_message(status, 'status', msg_id)
270 validate_message(status, 'status', msg_id)
268 nt.assert_equal(status['content']['execution_state'], 'idle')
271 nt.assert_equal(status['content']['execution_state'], 'idle')
269
272
270 nt.assert_raises(Empty, KC.iopub_channel.get_msg, timeout=0.1)
273 nt.assert_raises(Empty, KC.iopub_channel.get_msg, timeout=0.1)
271 count_2 = reply['execution_count']
274 count_2 = reply['execution_count']
272 nt.assert_equal(count_2, count)
275 nt.assert_equal(count_2, count)
273
276
274
277
275 def test_execute_error():
278 def test_execute_error():
276 flush_channels()
279 flush_channels()
277
280
278 msg_id, reply = execute(code='1/0')
281 msg_id, reply = execute(code='1/0')
279 nt.assert_equal(reply['status'], 'error')
282 nt.assert_equal(reply['status'], 'error')
280 nt.assert_equal(reply['ename'], 'ZeroDivisionError')
283 nt.assert_equal(reply['ename'], 'ZeroDivisionError')
281
284
282 error = KC.iopub_channel.get_msg(timeout=TIMEOUT)
285 error = KC.iopub_channel.get_msg(timeout=TIMEOUT)
283 validate_message(error, 'error', msg_id)
286 validate_message(error, 'error', msg_id)
284
287
285
288
286 def test_execute_inc():
289 def test_execute_inc():
287 """execute request should increment execution_count"""
290 """execute request should increment execution_count"""
288 flush_channels()
291 flush_channels()
289
292
290 msg_id, reply = execute(code='x=1')
293 msg_id, reply = execute(code='x=1')
291 count = reply['execution_count']
294 count = reply['execution_count']
292
295
293 flush_channels()
296 flush_channels()
294
297
295 msg_id, reply = execute(code='x=2')
298 msg_id, reply = execute(code='x=2')
296 count_2 = reply['execution_count']
299 count_2 = reply['execution_count']
297 nt.assert_equal(count_2, count+1)
300 nt.assert_equal(count_2, count+1)
298
301
299
302
300 def test_user_expressions():
303 def test_user_expressions():
301 flush_channels()
304 flush_channels()
302
305
303 msg_id, reply = execute(code='x=1', user_expressions=dict(foo='x+1'))
306 msg_id, reply = execute(code='x=1', user_expressions=dict(foo='x+1'))
304 user_expressions = reply['user_expressions']
307 user_expressions = reply['user_expressions']
305 nt.assert_equal(user_expressions, {u'foo': {
308 nt.assert_equal(user_expressions, {u'foo': {
306 u'status': u'ok',
309 u'status': u'ok',
307 u'data': {u'text/plain': u'2'},
310 u'data': {u'text/plain': u'2'},
308 u'metadata': {},
311 u'metadata': {},
309 }})
312 }})
310
313
311
314
312 def test_user_expressions_fail():
315 def test_user_expressions_fail():
313 flush_channels()
316 flush_channels()
314
317
315 msg_id, reply = execute(code='x=0', user_expressions=dict(foo='nosuchname'))
318 msg_id, reply = execute(code='x=0', user_expressions=dict(foo='nosuchname'))
316 user_expressions = reply['user_expressions']
319 user_expressions = reply['user_expressions']
317 foo = user_expressions['foo']
320 foo = user_expressions['foo']
318 nt.assert_equal(foo['status'], 'error')
321 nt.assert_equal(foo['status'], 'error')
319 nt.assert_equal(foo['ename'], 'NameError')
322 nt.assert_equal(foo['ename'], 'NameError')
320
323
321
324
322 def test_oinfo():
325 def test_oinfo():
323 flush_channels()
326 flush_channels()
324
327
325 msg_id = KC.inspect('a')
328 msg_id = KC.inspect('a')
326 reply = KC.get_shell_msg(timeout=TIMEOUT)
329 reply = KC.get_shell_msg(timeout=TIMEOUT)
327 validate_message(reply, 'inspect_reply', msg_id)
330 validate_message(reply, 'inspect_reply', msg_id)
328
331
329
332
330 def test_oinfo_found():
333 def test_oinfo_found():
331 flush_channels()
334 flush_channels()
332
335
333 msg_id, reply = execute(code='a=5')
336 msg_id, reply = execute(code='a=5')
334
337
335 msg_id = KC.inspect('a')
338 msg_id = KC.inspect('a')
336 reply = KC.get_shell_msg(timeout=TIMEOUT)
339 reply = KC.get_shell_msg(timeout=TIMEOUT)
337 validate_message(reply, 'inspect_reply', msg_id)
340 validate_message(reply, 'inspect_reply', msg_id)
338 content = reply['content']
341 content = reply['content']
339 assert content['found']
342 assert content['found']
340 text = content['data']['text/plain']
343 text = content['data']['text/plain']
341 nt.assert_in('Type:', text)
344 nt.assert_in('Type:', text)
342 nt.assert_in('Docstring:', text)
345 nt.assert_in('Docstring:', text)
343
346
344
347
345 def test_oinfo_detail():
348 def test_oinfo_detail():
346 flush_channels()
349 flush_channels()
347
350
348 msg_id, reply = execute(code='ip=get_ipython()')
351 msg_id, reply = execute(code='ip=get_ipython()')
349
352
350 msg_id = KC.inspect('ip.object_inspect', cursor_pos=10, detail_level=1)
353 msg_id = KC.inspect('ip.object_inspect', cursor_pos=10, detail_level=1)
351 reply = KC.get_shell_msg(timeout=TIMEOUT)
354 reply = KC.get_shell_msg(timeout=TIMEOUT)
352 validate_message(reply, 'inspect_reply', msg_id)
355 validate_message(reply, 'inspect_reply', msg_id)
353 content = reply['content']
356 content = reply['content']
354 assert content['found']
357 assert content['found']
355 text = content['data']['text/plain']
358 text = content['data']['text/plain']
356 nt.assert_in('Definition:', text)
359 nt.assert_in('Definition:', text)
357 nt.assert_in('Source:', text)
360 nt.assert_in('Source:', text)
358
361
359
362
360 def test_oinfo_not_found():
363 def test_oinfo_not_found():
361 flush_channels()
364 flush_channels()
362
365
363 msg_id = KC.inspect('dne')
366 msg_id = KC.inspect('dne')
364 reply = KC.get_shell_msg(timeout=TIMEOUT)
367 reply = KC.get_shell_msg(timeout=TIMEOUT)
365 validate_message(reply, 'inspect_reply', msg_id)
368 validate_message(reply, 'inspect_reply', msg_id)
366 content = reply['content']
369 content = reply['content']
367 nt.assert_false(content['found'])
370 nt.assert_false(content['found'])
368
371
369
372
370 def test_complete():
373 def test_complete():
371 flush_channels()
374 flush_channels()
372
375
373 msg_id, reply = execute(code="alpha = albert = 5")
376 msg_id, reply = execute(code="alpha = albert = 5")
374
377
375 msg_id = KC.complete('al', 2)
378 msg_id = KC.complete('al', 2)
376 reply = KC.get_shell_msg(timeout=TIMEOUT)
379 reply = KC.get_shell_msg(timeout=TIMEOUT)
377 validate_message(reply, 'complete_reply', msg_id)
380 validate_message(reply, 'complete_reply', msg_id)
378 matches = reply['content']['matches']
381 matches = reply['content']['matches']
379 for name in ('alpha', 'albert'):
382 for name in ('alpha', 'albert'):
380 nt.assert_in(name, matches)
383 nt.assert_in(name, matches)
381
384
382
385
383 def test_kernel_info_request():
386 def test_kernel_info_request():
384 flush_channels()
387 flush_channels()
385
388
386 msg_id = KC.kernel_info()
389 msg_id = KC.kernel_info()
387 reply = KC.get_shell_msg(timeout=TIMEOUT)
390 reply = KC.get_shell_msg(timeout=TIMEOUT)
388 validate_message(reply, 'kernel_info_reply', msg_id)
391 validate_message(reply, 'kernel_info_reply', msg_id)
389
392
390
393
391 def test_single_payload():
394 def test_single_payload():
392 flush_channels()
395 flush_channels()
393 msg_id, reply = execute(code="for i in range(3):\n"+
396 msg_id, reply = execute(code="for i in range(3):\n"+
394 " x=range?\n")
397 " x=range?\n")
395 payload = reply['payload']
398 payload = reply['payload']
396 next_input_pls = [pl for pl in payload if pl["source"] == "set_next_input"]
399 next_input_pls = [pl for pl in payload if pl["source"] == "set_next_input"]
397 nt.assert_equal(len(next_input_pls), 1)
400 nt.assert_equal(len(next_input_pls), 1)
398
401
399 def test_is_complete():
402 def test_is_complete():
400 flush_channels()
403 flush_channels()
401
404
402 msg_id = KC.is_complete("a = 1")
405 msg_id = KC.is_complete("a = 1")
403 reply = KC.get_shell_msg(timeout=TIMEOUT)
406 reply = KC.get_shell_msg(timeout=TIMEOUT)
404 validate_message(reply, 'is_complete_reply', msg_id)
407 validate_message(reply, 'is_complete_reply', msg_id)
405
408
406 # IOPub channel
409 # IOPub channel
407
410
408
411
409 def test_stream():
412 def test_stream():
410 flush_channels()
413 flush_channels()
411
414
412 msg_id, reply = execute("print('hi')")
415 msg_id, reply = execute("print('hi')")
413
416
414 stdout = KC.iopub_channel.get_msg(timeout=TIMEOUT)
417 stdout = KC.iopub_channel.get_msg(timeout=TIMEOUT)
415 validate_message(stdout, 'stream', msg_id)
418 validate_message(stdout, 'stream', msg_id)
416 content = stdout['content']
419 content = stdout['content']
417 nt.assert_equal(content['text'], u'hi\n')
420 nt.assert_equal(content['text'], u'hi\n')
418
421
419
422
420 def test_display_data():
423 def test_display_data():
421 flush_channels()
424 flush_channels()
422
425
423 msg_id, reply = execute("from IPython.core.display import display; display(1)")
426 msg_id, reply = execute("from IPython.core.display import display; display(1)")
424
427
425 display = KC.iopub_channel.get_msg(timeout=TIMEOUT)
428 display = KC.iopub_channel.get_msg(timeout=TIMEOUT)
426 validate_message(display, 'display_data', parent=msg_id)
429 validate_message(display, 'display_data', parent=msg_id)
427 data = display['content']['data']
430 data = display['content']['data']
428 nt.assert_equal(data['text/plain'], u'1')
431 nt.assert_equal(data['text/plain'], u'1')
429
432
General Comments 0
You need to be logged in to leave comments. Login now