##// END OF EJS Templates
Merge pull request #4188 from takluyver/dict-traitlet-none...
Min RK -
r12480:87d41d78 merge
parent child Browse files
Show More
@@ -201,7 +201,7 b' class InteractiveShellApp(Configurable):'
201 )
201 )
202 shell = Instance('IPython.core.interactiveshell.InteractiveShellABC')
202 shell = Instance('IPython.core.interactiveshell.InteractiveShellABC')
203
203
204 user_ns = Dict(default_value=None)
204 user_ns = Instance(dict, args=None, allow_none=True)
205 def _user_ns_changed(self, name, old, new):
205 def _user_ns_changed(self, name, old, new):
206 if self.shell is not None:
206 if self.shell is not None:
207 self.shell.user_ns = new
207 self.shell.user_ns = new
@@ -87,7 +87,7 b' class Kernel(Configurable):'
87 if self.shell is not None:
87 if self.shell is not None:
88 self.shell.user_module = new
88 self.shell.user_module = new
89
89
90 user_ns = Dict(default_value=None)
90 user_ns = Instance(dict, args=None, allow_none=True)
91 def _user_ns_changed(self, name, old, new):
91 def _user_ns_changed(self, name, old, new):
92 if self.shell is not None:
92 if self.shell is not None:
93 self.shell.user_ns = new
93 self.shell.user_ns = new
@@ -8,10 +8,38 b' def test_ipython_start_kernel_userns():'
8 cmd = ('from IPython import start_kernel\n'
8 cmd = ('from IPython import start_kernel\n'
9 'ns = {"tre": 123}\n'
9 'ns = {"tre": 123}\n'
10 'start_kernel(user_ns=ns)')
10 'start_kernel(user_ns=ns)')
11
11
12 with setup_kernel(cmd) as client:
12 with setup_kernel(cmd) as client:
13 msg_id = client.object_info('tre')
13 msg_id = client.object_info('tre')
14 msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
14 msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
15 content = msg['content']
15 content = msg['content']
16 assert content['found']
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