@@ -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 .iopub_channel )
32+ stdout , stderr = assemble_output (kc .get_iopub_msg )
3333 assert stdout .strip () == repr (expected )
3434
3535
@@ -44,9 +44,8 @@ def _check_status(content):
4444def test_simple_print ():
4545 """simple print statement in kernel"""
4646 with kernel () as kc :
47- iopub = kc .iopub_channel
4847 msg_id , content = execute (kc = kc , code = "print ('hi')" )
49- stdout , stderr = assemble_output (iopub )
48+ stdout , stderr = assemble_output (kc . get_iopub_msg )
5049 assert stdout == 'hi\n '
5150 assert stderr == ''
5251 _check_master (kc , expected = True )
@@ -56,7 +55,7 @@ def test_sys_path():
5655 """test that sys.path doesn't get messed up by default"""
5756 with kernel () as kc :
5857 msg_id , content = execute (kc = kc , code = "import sys; print(repr(sys.path))" )
59- stdout , stderr = assemble_output (kc .iopub_channel )
58+ stdout , stderr = assemble_output (kc .get_iopub_msg )
6059 # for error-output on failure
6160 sys .stderr .write (stderr )
6261
@@ -69,7 +68,7 @@ def test_sys_path_profile_dir():
6968
7069 with new_kernel (['--profile-dir' , locate_profile ('default' )]) as kc :
7170 msg_id , content = execute (kc = kc , code = "import sys; print(repr(sys.path))" )
72- stdout , stderr = assemble_output (kc .iopub_channel )
71+ stdout , stderr = assemble_output (kc .get_iopub_msg )
7372 # for error-output on failure
7473 sys .stderr .write (stderr )
7574
@@ -85,8 +84,6 @@ def test_sys_path_profile_dir():
8584def test_subprocess_print ():
8685 """printing from forked mp.Process"""
8786 with new_kernel () as kc :
88- iopub = kc .iopub_channel
89-
9087 _check_master (kc , expected = True )
9188 flush_channels (kc )
9289 np = 5
@@ -100,7 +97,7 @@ def test_subprocess_print():
10097 ])
10198
10299 msg_id , content = execute (kc = kc , code = code )
103- stdout , stderr = assemble_output (iopub )
100+ stdout , stderr = assemble_output (kc . get_iopub_msg )
104101 nt .assert_equal (stdout .count ("hello" ), np , stdout )
105102 for n in range (np ):
106103 nt .assert_equal (stdout .count (str (n )), 1 , stdout )
@@ -113,8 +110,6 @@ def test_subprocess_print():
113110def test_subprocess_noprint ():
114111 """mp.Process without print doesn't trigger iostream mp_mode"""
115112 with kernel () as kc :
116- iopub = kc .iopub_channel
117-
118113 np = 5
119114 code = '\n ' .join ([
120115 "import multiprocessing as mp" ,
@@ -124,7 +119,7 @@ def test_subprocess_noprint():
124119 ])
125120
126121 msg_id , content = execute (kc = kc , code = code )
127- stdout , stderr = assemble_output (iopub )
122+ stdout , stderr = assemble_output (kc . get_iopub_msg )
128123 assert stdout == ''
129124 assert stderr == ''
130125
@@ -140,8 +135,6 @@ def test_subprocess_noprint():
140135def test_subprocess_error ():
141136 """error in mp.Process doesn't crash"""
142137 with new_kernel () as kc :
143- iopub = kc .iopub_channel
144-
145138 code = '\n ' .join ([
146139 "import multiprocessing as mp" ,
147140 "p = mp.Process(target=int, args=('hi',))" ,
@@ -150,7 +143,7 @@ def test_subprocess_error():
150143 ])
151144
152145 msg_id , content = execute (kc = kc , code = code )
153- stdout , stderr = assemble_output (iopub )
146+ stdout , stderr = assemble_output (kc . get_iopub_msg )
154147 assert stdout == ''
155148 assert "ValueError" in stderr
156149
@@ -162,8 +155,6 @@ def test_subprocess_error():
162155def test_raw_input ():
163156 """test input"""
164157 with kernel () as kc :
165- iopub = kc .iopub_channel
166-
167158 input_f = "input"
168159 theprompt = "prompt> "
169160 code = 'print({input_f}("{theprompt}"))' .format (** locals ())
@@ -176,7 +167,7 @@ def test_raw_input():
176167 kc .input (text )
177168 reply = kc .get_shell_msg (block = True , timeout = TIMEOUT )
178169 assert reply ['content' ]['status' ] == 'ok'
179- stdout , stderr = assemble_output (iopub )
170+ stdout , stderr = assemble_output (kc . get_iopub_msg )
180171 assert stdout == text + "\n "
181172
182173
@@ -313,19 +304,17 @@ def test_unc_paths():
313304 file_path = os .path .splitdrive (os .path .dirname (drive_file_path ))[1 ]
314305 unc_file_path = os .path .join (unc_root , file_path [1 :])
315306
316- iopub = kc .iopub_channel
317-
318307 kc .execute ("cd {0:s}" .format (unc_file_path ))
319308 reply = kc .get_shell_msg (block = True , timeout = TIMEOUT )
320309 assert reply ['content' ]['status' ] == 'ok'
321- out , err = assemble_output (iopub )
310+ out , err = assemble_output (kc . get_iopub_msg )
322311 assert unc_file_path in out
323312
324313 flush_channels (kc )
325314 kc .execute (code = "ls" )
326315 reply = kc .get_shell_msg (block = True , timeout = TIMEOUT )
327316 assert reply ['content' ]['status' ] == 'ok'
328- out , err = assemble_output (iopub )
317+ out , err = assemble_output (kc . get_iopub_msg )
329318 assert 'unc.txt' in out
330319
331320 kc .execute (code = "cd" )
0 commit comments