@@ -29,7 +29,7 @@ def _check_master(kc, expected=True, stream="stdout"):
2929 execute (kc = kc , code = "import sys" )
3030 flush_channels (kc )
3131 msg_id , content = execute (kc = kc , code = "print (sys.%s._is_master_process())" % stream )
32- stdout , stderr = assemble_output (kc .get_iopub_msg )
32+ stdout , stderr = assemble_output (kc .iopub_channel )
3333 assert stdout .strip () == repr (expected )
3434
3535
@@ -44,8 +44,9 @@ def _check_status(content):
4444def test_simple_print ():
4545 """simple print statement in kernel"""
4646 with kernel () as kc :
47+ iopub = kc .iopub_channel
4748 msg_id , content = execute (kc = kc , code = "print ('hi')" )
48- stdout , stderr = assemble_output (kc . get_iopub_msg )
49+ stdout , stderr = assemble_output (iopub )
4950 assert stdout == 'hi\n '
5051 assert stderr == ''
5152 _check_master (kc , expected = True )
@@ -55,7 +56,7 @@ def test_sys_path():
5556 """test that sys.path doesn't get messed up by default"""
5657 with kernel () as kc :
5758 msg_id , content = execute (kc = kc , code = "import sys; print(repr(sys.path))" )
58- stdout , stderr = assemble_output (kc .get_iopub_msg )
59+ stdout , stderr = assemble_output (kc .iopub_channel )
5960 # for error-output on failure
6061 sys .stderr .write (stderr )
6162
@@ -68,7 +69,7 @@ def test_sys_path_profile_dir():
6869
6970 with new_kernel (['--profile-dir' , locate_profile ('default' )]) as kc :
7071 msg_id , content = execute (kc = kc , code = "import sys; print(repr(sys.path))" )
71- stdout , stderr = assemble_output (kc .get_iopub_msg )
72+ stdout , stderr = assemble_output (kc .iopub_channel )
7273 # for error-output on failure
7374 sys .stderr .write (stderr )
7475
@@ -84,6 +85,8 @@ def test_sys_path_profile_dir():
8485def test_subprocess_print ():
8586 """printing from forked mp.Process"""
8687 with new_kernel () as kc :
88+ iopub = kc .iopub_channel
89+
8790 _check_master (kc , expected = True )
8891 flush_channels (kc )
8992 np = 5
@@ -97,7 +100,7 @@ def test_subprocess_print():
97100 ])
98101
99102 msg_id , content = execute (kc = kc , code = code )
100- stdout , stderr = assemble_output (kc . get_iopub_msg )
103+ stdout , stderr = assemble_output (iopub )
101104 nt .assert_equal (stdout .count ("hello" ), np , stdout )
102105 for n in range (np ):
103106 nt .assert_equal (stdout .count (str (n )), 1 , stdout )
@@ -110,6 +113,8 @@ def test_subprocess_print():
110113def test_subprocess_noprint ():
111114 """mp.Process without print doesn't trigger iostream mp_mode"""
112115 with kernel () as kc :
116+ iopub = kc .iopub_channel
117+
113118 np = 5
114119 code = '\n ' .join ([
115120 "import multiprocessing as mp" ,
@@ -119,7 +124,7 @@ def test_subprocess_noprint():
119124 ])
120125
121126 msg_id , content = execute (kc = kc , code = code )
122- stdout , stderr = assemble_output (kc . get_iopub_msg )
127+ stdout , stderr = assemble_output (iopub )
123128 assert stdout == ''
124129 assert stderr == ''
125130
@@ -135,6 +140,8 @@ def test_subprocess_noprint():
135140def test_subprocess_error ():
136141 """error in mp.Process doesn't crash"""
137142 with new_kernel () as kc :
143+ iopub = kc .iopub_channel
144+
138145 code = '\n ' .join ([
139146 "import multiprocessing as mp" ,
140147 "p = mp.Process(target=int, args=('hi',))" ,
@@ -143,7 +150,7 @@ def test_subprocess_error():
143150 ])
144151
145152 msg_id , content = execute (kc = kc , code = code )
146- stdout , stderr = assemble_output (kc . get_iopub_msg )
153+ stdout , stderr = assemble_output (iopub )
147154 assert stdout == ''
148155 assert "ValueError" in stderr
149156
@@ -155,6 +162,8 @@ def test_subprocess_error():
155162def test_raw_input ():
156163 """test input"""
157164 with kernel () as kc :
165+ iopub = kc .iopub_channel
166+
158167 input_f = "input"
159168 theprompt = "prompt> "
160169 code = 'print({input_f}("{theprompt}"))' .format (** locals ())
@@ -167,7 +176,7 @@ def test_raw_input():
167176 kc .input (text )
168177 reply = kc .get_shell_msg (block = True , timeout = TIMEOUT )
169178 assert reply ['content' ]['status' ] == 'ok'
170- stdout , stderr = assemble_output (kc . get_iopub_msg )
179+ stdout , stderr = assemble_output (iopub )
171180 assert stdout == text + "\n "
172181
173182
@@ -304,17 +313,19 @@ def test_unc_paths():
304313 file_path = os .path .splitdrive (os .path .dirname (drive_file_path ))[1 ]
305314 unc_file_path = os .path .join (unc_root , file_path [1 :])
306315
316+ iopub = kc .iopub_channel
317+
307318 kc .execute ("cd {0:s}" .format (unc_file_path ))
308319 reply = kc .get_shell_msg (block = True , timeout = TIMEOUT )
309320 assert reply ['content' ]['status' ] == 'ok'
310- out , err = assemble_output (kc . get_iopub_msg )
321+ out , err = assemble_output (iopub )
311322 assert unc_file_path in out
312323
313324 flush_channels (kc )
314325 kc .execute (code = "ls" )
315326 reply = kc .get_shell_msg (block = True , timeout = TIMEOUT )
316327 assert reply ['content' ]['status' ] == 'ok'
317- out , err = assemble_output (kc . get_iopub_msg )
328+ out , err = assemble_output (iopub )
318329 assert 'unc.txt' in out
319330
320331 kc .execute (code = "cd" )
0 commit comments