Show More
@@ -8,10 +8,38 b' def test_ipython_start_kernel_userns():' | |||
|
8 | 8 | cmd = ('from IPython import start_kernel\n' |
|
9 | 9 | 'ns = {"tre": 123}\n' |
|
10 | 10 | 'start_kernel(user_ns=ns)') |
|
11 | ||
|
11 | ||
|
12 | 12 | with setup_kernel(cmd) as client: |
|
13 | 13 | msg_id = client.object_info('tre') |
|
14 | 14 | msg = client.get_shell_msg(block=True, timeout=TIMEOUT) |
|
15 | 15 | content = msg['content'] |
|
16 | 16 | assert content['found'] |
|
17 | nt.assert_equal(content['string_form'], u'123') No newline at end of file | |
|
17 | nt.assert_equal(content['string_form'], u'123') | |
|
18 | ||
|
19 | # user_module should be an instance of DummyMod | |
|
20 | msg_id = client.execute("usermod = get_ipython().user_module") | |
|
21 | msg = client.get_shell_msg(block=True, timeout=TIMEOUT) | |
|
22 | content = msg['content'] | |
|
23 | nt.assert_equal(content['status'], u'ok') | |
|
24 | msg_id = client.object_info('usermod') | |
|
25 | msg = client.get_shell_msg(block=True, timeout=TIMEOUT) | |
|
26 | content = msg['content'] | |
|
27 | assert content['found'] | |
|
28 | nt.assert_in('DummyMod', content['string_form']) | |
|
29 | ||
|
30 | def test_ipython_start_kernel_no_userns(): | |
|
31 | # Issue #4188 - user_ns should be passed to shell as None, not {} | |
|
32 | cmd = ('from IPython import start_kernel\n' | |
|
33 | 'start_kernel()') | |
|
34 | ||
|
35 | with setup_kernel(cmd) as client: | |
|
36 | # user_module should not be an instance of DummyMod | |
|
37 | msg_id = client.execute("usermod = get_ipython().user_module") | |
|
38 | msg = client.get_shell_msg(block=True, timeout=TIMEOUT) | |
|
39 | content = msg['content'] | |
|
40 | nt.assert_equal(content['status'], u'ok') | |
|
41 | msg_id = client.object_info('usermod') | |
|
42 | msg = client.get_shell_msg(block=True, timeout=TIMEOUT) | |
|
43 | content = msg['content'] | |
|
44 | assert content['found'] | |
|
45 | nt.assert_not_in('DummyMod', content['string_form']) |
General Comments 0
You need to be logged in to leave comments.
Login now