##// END OF EJS Templates
test re-entrant embed_kernel
MinRK -
Show More
@@ -156,3 +156,33 b' def test_embed_kernel_namespace():'
156 content = msg['content']
156 content = msg['content']
157 nt.assert_false(content['found'])
157 nt.assert_false(content['found'])
158
158
159 def test_embed_kernel_reentrant():
160 """IPython.embed_kernel() can be called multiple times"""
161 cmd = '\n'.join([
162 'from IPython import embed_kernel',
163 'count = 0',
164 'def go():',
165 ' global count',
166 ' embed_kernel()',
167 ' count = count + 1',
168 '',
169 'while True:'
170 ' go()',
171 '',
172 ])
173
174 with setup_kernel(cmd) as km:
175 shell = km.shell_channel
176 for i in range(5):
177 msg_id = shell.object_info('count')
178 msg = shell.get_msg(block=True, timeout=2)
179 content = msg['content']
180 nt.assert_true(content['found'])
181 nt.assert_equals(content['string_form'], unicode(i))
182
183 # exit from embed_kernel
184 shell.execute("get_ipython().exit_now = True")
185 msg = shell.get_msg(block=True, timeout=2)
186 time.sleep(0.2)
187
188
General Comments 0
You need to be logged in to leave comments. Login now