##// END OF EJS Templates
add a few pxconfig tests
MinRK -
Show More
@@ -1,377 +1,383 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """Test Parallel magics
2 """Test Parallel magics
3
3
4 Authors:
4 Authors:
5
5
6 * Min RK
6 * Min RK
7 """
7 """
8 #-------------------------------------------------------------------------------
8 #-------------------------------------------------------------------------------
9 # Copyright (C) 2011 The IPython Development Team
9 # Copyright (C) 2011 The IPython Development Team
10 #
10 #
11 # Distributed under the terms of the BSD License. The full license is in
11 # Distributed under the terms of the BSD License. The full license is in
12 # the file COPYING, distributed as part of this software.
12 # the file COPYING, distributed as part of this software.
13 #-------------------------------------------------------------------------------
13 #-------------------------------------------------------------------------------
14
14
15 #-------------------------------------------------------------------------------
15 #-------------------------------------------------------------------------------
16 # Imports
16 # Imports
17 #-------------------------------------------------------------------------------
17 #-------------------------------------------------------------------------------
18
18
19 import re
19 import re
20 import sys
20 import sys
21 import time
21 import time
22
22
23 import zmq
23 import zmq
24 from nose import SkipTest
24 from nose import SkipTest
25
25
26 from IPython.testing import decorators as dec
26 from IPython.testing import decorators as dec
27 from IPython.testing.ipunittest import ParametricTestCase
27 from IPython.testing.ipunittest import ParametricTestCase
28 from IPython.utils.io import capture_output
28 from IPython.utils.io import capture_output
29
29
30 from IPython import parallel as pmod
30 from IPython import parallel as pmod
31 from IPython.parallel import error
31 from IPython.parallel import error
32 from IPython.parallel import AsyncResult
32 from IPython.parallel import AsyncResult
33 from IPython.parallel.util import interactive
33 from IPython.parallel.util import interactive
34
34
35 from IPython.parallel.tests import add_engines
35 from IPython.parallel.tests import add_engines
36
36
37 from .clienttest import ClusterTestCase, generate_output
37 from .clienttest import ClusterTestCase, generate_output
38
38
39 def setup():
39 def setup():
40 add_engines(3, total=True)
40 add_engines(3, total=True)
41
41
42 class TestParallelMagics(ClusterTestCase, ParametricTestCase):
42 class TestParallelMagics(ClusterTestCase, ParametricTestCase):
43
43
44 def test_px_blocking(self):
44 def test_px_blocking(self):
45 ip = get_ipython()
45 ip = get_ipython()
46 v = self.client[-1:]
46 v = self.client[-1:]
47 v.activate()
47 v.activate()
48 v.block=True
48 v.block=True
49
49
50 ip.magic('px a=5')
50 ip.magic('px a=5')
51 self.assertEquals(v['a'], [5])
51 self.assertEquals(v['a'], [5])
52 ip.magic('px a=10')
52 ip.magic('px a=10')
53 self.assertEquals(v['a'], [10])
53 self.assertEquals(v['a'], [10])
54 # just 'print a' works ~99% of the time, but this ensures that
54 # just 'print a' works ~99% of the time, but this ensures that
55 # the stdout message has arrived when the result is finished:
55 # the stdout message has arrived when the result is finished:
56 with capture_output() as io:
56 with capture_output() as io:
57 ip.magic(
57 ip.magic(
58 'px import sys,time;print(a);sys.stdout.flush();time.sleep(0.2)'
58 'px import sys,time;print(a);sys.stdout.flush();time.sleep(0.2)'
59 )
59 )
60 out = io.stdout
60 out = io.stdout
61 self.assertTrue('[stdout:' in out, out)
61 self.assertTrue('[stdout:' in out, out)
62 self.assertFalse('\n\n' in out)
62 self.assertFalse('\n\n' in out)
63 self.assertTrue(out.rstrip().endswith('10'))
63 self.assertTrue(out.rstrip().endswith('10'))
64 self.assertRaisesRemote(ZeroDivisionError, ip.magic, 'px 1/0')
64 self.assertRaisesRemote(ZeroDivisionError, ip.magic, 'px 1/0')
65
65
66 def _check_generated_stderr(self, stderr, n):
66 def _check_generated_stderr(self, stderr, n):
67 expected = [
67 expected = [
68 r'\[stderr:\d+\]',
68 r'\[stderr:\d+\]',
69 '^stderr$',
69 '^stderr$',
70 '^stderr2$',
70 '^stderr2$',
71 ] * n
71 ] * n
72
72
73 self.assertFalse('\n\n' in stderr, stderr)
73 self.assertFalse('\n\n' in stderr, stderr)
74 lines = stderr.splitlines()
74 lines = stderr.splitlines()
75 self.assertEquals(len(lines), len(expected), stderr)
75 self.assertEquals(len(lines), len(expected), stderr)
76 for line,expect in zip(lines, expected):
76 for line,expect in zip(lines, expected):
77 if isinstance(expect, str):
77 if isinstance(expect, str):
78 expect = [expect]
78 expect = [expect]
79 for ex in expect:
79 for ex in expect:
80 self.assertTrue(re.search(ex, line) is not None, "Expected %r in %r" % (ex, line))
80 self.assertTrue(re.search(ex, line) is not None, "Expected %r in %r" % (ex, line))
81
81
82 def test_cellpx_block_args(self):
82 def test_cellpx_block_args(self):
83 """%%px --[no]block flags work"""
83 """%%px --[no]block flags work"""
84 ip = get_ipython()
84 ip = get_ipython()
85 v = self.client[-1:]
85 v = self.client[-1:]
86 v.activate()
86 v.activate()
87 v.block=False
87 v.block=False
88
88
89 for block in (True, False):
89 for block in (True, False):
90 v.block = block
90 v.block = block
91
91
92 with capture_output() as io:
92 with capture_output() as io:
93 ip.run_cell_magic("px", "", "1")
93 ip.run_cell_magic("px", "", "1")
94 if block:
94 if block:
95 self.assertTrue(io.stdout.startswith("Parallel"), io.stdout)
95 self.assertTrue(io.stdout.startswith("Parallel"), io.stdout)
96 else:
96 else:
97 self.assertTrue(io.stdout.startswith("Async"), io.stdout)
97 self.assertTrue(io.stdout.startswith("Async"), io.stdout)
98
98
99 with capture_output() as io:
99 with capture_output() as io:
100 ip.run_cell_magic("px", "--block", "1")
100 ip.run_cell_magic("px", "--block", "1")
101 self.assertTrue(io.stdout.startswith("Parallel"), io.stdout)
101 self.assertTrue(io.stdout.startswith("Parallel"), io.stdout)
102
102
103 with capture_output() as io:
103 with capture_output() as io:
104 ip.run_cell_magic("px", "--noblock", "1")
104 ip.run_cell_magic("px", "--noblock", "1")
105 self.assertTrue(io.stdout.startswith("Async"), io.stdout)
105 self.assertTrue(io.stdout.startswith("Async"), io.stdout)
106
106
107 def test_cellpx_groupby_engine(self):
107 def test_cellpx_groupby_engine(self):
108 """%%px --group-outputs=engine"""
108 """%%px --group-outputs=engine"""
109 ip = get_ipython()
109 ip = get_ipython()
110 v = self.client[:]
110 v = self.client[:]
111 v.block = True
111 v.block = True
112 v.activate()
112 v.activate()
113
113
114 v['generate_output'] = generate_output
114 v['generate_output'] = generate_output
115
115
116 with capture_output() as io:
116 with capture_output() as io:
117 ip.run_cell_magic('px', '--group-outputs=engine', 'generate_output()')
117 ip.run_cell_magic('px', '--group-outputs=engine', 'generate_output()')
118
118
119 self.assertFalse('\n\n' in io.stdout)
119 self.assertFalse('\n\n' in io.stdout)
120 lines = io.stdout.splitlines()[1:]
120 lines = io.stdout.splitlines()[1:]
121 expected = [
121 expected = [
122 r'\[stdout:\d+\]',
122 r'\[stdout:\d+\]',
123 'stdout',
123 'stdout',
124 'stdout2',
124 'stdout2',
125 r'\[output:\d+\]',
125 r'\[output:\d+\]',
126 r'IPython\.core\.display\.HTML',
126 r'IPython\.core\.display\.HTML',
127 r'IPython\.core\.display\.Math',
127 r'IPython\.core\.display\.Math',
128 r'Out\[\d+:\d+\]:.*IPython\.core\.display\.Math',
128 r'Out\[\d+:\d+\]:.*IPython\.core\.display\.Math',
129 ] * len(v)
129 ] * len(v)
130
130
131 self.assertEquals(len(lines), len(expected), io.stdout)
131 self.assertEquals(len(lines), len(expected), io.stdout)
132 for line,expect in zip(lines, expected):
132 for line,expect in zip(lines, expected):
133 if isinstance(expect, str):
133 if isinstance(expect, str):
134 expect = [expect]
134 expect = [expect]
135 for ex in expect:
135 for ex in expect:
136 self.assertTrue(re.search(ex, line) is not None, "Expected %r in %r" % (ex, line))
136 self.assertTrue(re.search(ex, line) is not None, "Expected %r in %r" % (ex, line))
137
137
138 self._check_generated_stderr(io.stderr, len(v))
138 self._check_generated_stderr(io.stderr, len(v))
139
139
140
140
141 def test_cellpx_groupby_order(self):
141 def test_cellpx_groupby_order(self):
142 """%%px --group-outputs=order"""
142 """%%px --group-outputs=order"""
143 ip = get_ipython()
143 ip = get_ipython()
144 v = self.client[:]
144 v = self.client[:]
145 v.block = True
145 v.block = True
146 v.activate()
146 v.activate()
147
147
148 v['generate_output'] = generate_output
148 v['generate_output'] = generate_output
149
149
150 with capture_output() as io:
150 with capture_output() as io:
151 ip.run_cell_magic('px', '--group-outputs=order', 'generate_output()')
151 ip.run_cell_magic('px', '--group-outputs=order', 'generate_output()')
152
152
153 self.assertFalse('\n\n' in io.stdout)
153 self.assertFalse('\n\n' in io.stdout)
154 lines = io.stdout.splitlines()[1:]
154 lines = io.stdout.splitlines()[1:]
155 expected = []
155 expected = []
156 expected.extend([
156 expected.extend([
157 r'\[stdout:\d+\]',
157 r'\[stdout:\d+\]',
158 'stdout',
158 'stdout',
159 'stdout2',
159 'stdout2',
160 ] * len(v))
160 ] * len(v))
161 expected.extend([
161 expected.extend([
162 r'\[output:\d+\]',
162 r'\[output:\d+\]',
163 'IPython.core.display.HTML',
163 'IPython.core.display.HTML',
164 ] * len(v))
164 ] * len(v))
165 expected.extend([
165 expected.extend([
166 r'\[output:\d+\]',
166 r'\[output:\d+\]',
167 'IPython.core.display.Math',
167 'IPython.core.display.Math',
168 ] * len(v))
168 ] * len(v))
169 expected.extend([
169 expected.extend([
170 r'Out\[\d+:\d+\]:.*IPython\.core\.display\.Math'
170 r'Out\[\d+:\d+\]:.*IPython\.core\.display\.Math'
171 ] * len(v))
171 ] * len(v))
172
172
173 self.assertEquals(len(lines), len(expected), io.stdout)
173 self.assertEquals(len(lines), len(expected), io.stdout)
174 for line,expect in zip(lines, expected):
174 for line,expect in zip(lines, expected):
175 if isinstance(expect, str):
175 if isinstance(expect, str):
176 expect = [expect]
176 expect = [expect]
177 for ex in expect:
177 for ex in expect:
178 self.assertTrue(re.search(ex, line) is not None, "Expected %r in %r" % (ex, line))
178 self.assertTrue(re.search(ex, line) is not None, "Expected %r in %r" % (ex, line))
179
179
180 self._check_generated_stderr(io.stderr, len(v))
180 self._check_generated_stderr(io.stderr, len(v))
181
181
182 def test_cellpx_groupby_type(self):
182 def test_cellpx_groupby_type(self):
183 """%%px --group-outputs=type"""
183 """%%px --group-outputs=type"""
184 ip = get_ipython()
184 ip = get_ipython()
185 v = self.client[:]
185 v = self.client[:]
186 v.block = True
186 v.block = True
187 v.activate()
187 v.activate()
188
188
189 v['generate_output'] = generate_output
189 v['generate_output'] = generate_output
190
190
191 with capture_output() as io:
191 with capture_output() as io:
192 ip.run_cell_magic('px', '--group-outputs=type', 'generate_output()')
192 ip.run_cell_magic('px', '--group-outputs=type', 'generate_output()')
193
193
194 self.assertFalse('\n\n' in io.stdout)
194 self.assertFalse('\n\n' in io.stdout)
195 lines = io.stdout.splitlines()[1:]
195 lines = io.stdout.splitlines()[1:]
196
196
197 expected = []
197 expected = []
198 expected.extend([
198 expected.extend([
199 r'\[stdout:\d+\]',
199 r'\[stdout:\d+\]',
200 'stdout',
200 'stdout',
201 'stdout2',
201 'stdout2',
202 ] * len(v))
202 ] * len(v))
203 expected.extend([
203 expected.extend([
204 r'\[output:\d+\]',
204 r'\[output:\d+\]',
205 r'IPython\.core\.display\.HTML',
205 r'IPython\.core\.display\.HTML',
206 r'IPython\.core\.display\.Math',
206 r'IPython\.core\.display\.Math',
207 ] * len(v))
207 ] * len(v))
208 expected.extend([
208 expected.extend([
209 (r'Out\[\d+:\d+\]', r'IPython\.core\.display\.Math')
209 (r'Out\[\d+:\d+\]', r'IPython\.core\.display\.Math')
210 ] * len(v))
210 ] * len(v))
211
211
212 self.assertEquals(len(lines), len(expected), io.stdout)
212 self.assertEquals(len(lines), len(expected), io.stdout)
213 for line,expect in zip(lines, expected):
213 for line,expect in zip(lines, expected):
214 if isinstance(expect, str):
214 if isinstance(expect, str):
215 expect = [expect]
215 expect = [expect]
216 for ex in expect:
216 for ex in expect:
217 self.assertTrue(re.search(ex, line) is not None, "Expected %r in %r" % (ex, line))
217 self.assertTrue(re.search(ex, line) is not None, "Expected %r in %r" % (ex, line))
218
218
219 self._check_generated_stderr(io.stderr, len(v))
219 self._check_generated_stderr(io.stderr, len(v))
220
220
221
221
222 def test_px_nonblocking(self):
222 def test_px_nonblocking(self):
223 ip = get_ipython()
223 ip = get_ipython()
224 v = self.client[-1:]
224 v = self.client[-1:]
225 v.activate()
225 v.activate()
226 v.block=False
226 v.block=False
227
227
228 ip.magic('px a=5')
228 ip.magic('px a=5')
229 self.assertEquals(v['a'], [5])
229 self.assertEquals(v['a'], [5])
230 ip.magic('px a=10')
230 ip.magic('px a=10')
231 self.assertEquals(v['a'], [10])
231 self.assertEquals(v['a'], [10])
232 with capture_output() as io:
232 with capture_output() as io:
233 ar = ip.magic('px print (a)')
233 ar = ip.magic('px print (a)')
234 self.assertTrue(isinstance(ar, AsyncResult))
234 self.assertTrue(isinstance(ar, AsyncResult))
235 self.assertTrue('Async' in io.stdout)
235 self.assertTrue('Async' in io.stdout)
236 self.assertFalse('[stdout:' in io.stdout)
236 self.assertFalse('[stdout:' in io.stdout)
237 self.assertFalse('\n\n' in io.stdout)
237 self.assertFalse('\n\n' in io.stdout)
238
238
239 ar = ip.magic('px 1/0')
239 ar = ip.magic('px 1/0')
240 self.assertRaisesRemote(ZeroDivisionError, ar.get)
240 self.assertRaisesRemote(ZeroDivisionError, ar.get)
241
241
242 def test_autopx_blocking(self):
242 def test_autopx_blocking(self):
243 ip = get_ipython()
243 ip = get_ipython()
244 v = self.client[-1]
244 v = self.client[-1]
245 v.activate()
245 v.activate()
246 v.block=True
246 v.block=True
247
247
248 with capture_output() as io:
248 with capture_output() as io:
249 ip.magic('autopx')
249 ip.magic('autopx')
250 ip.run_cell('\n'.join(('a=5','b=12345','c=0')))
250 ip.run_cell('\n'.join(('a=5','b=12345','c=0')))
251 ip.run_cell('b*=2')
251 ip.run_cell('b*=2')
252 ip.run_cell('print (b)')
252 ip.run_cell('print (b)')
253 ip.run_cell('b')
253 ip.run_cell('b')
254 ip.run_cell("b/c")
254 ip.run_cell("b/c")
255 ip.magic('autopx')
255 ip.magic('autopx')
256
256
257 output = io.stdout
257 output = io.stdout
258
258
259 self.assertTrue(output.startswith('%autopx enabled'), output)
259 self.assertTrue(output.startswith('%autopx enabled'), output)
260 self.assertTrue(output.rstrip().endswith('%autopx disabled'), output)
260 self.assertTrue(output.rstrip().endswith('%autopx disabled'), output)
261 self.assertTrue('ZeroDivisionError' in output, output)
261 self.assertTrue('ZeroDivisionError' in output, output)
262 self.assertTrue('\nOut[' in output, output)
262 self.assertTrue('\nOut[' in output, output)
263 self.assertTrue(': 24690' in output, output)
263 self.assertTrue(': 24690' in output, output)
264 ar = v.get_result(-1)
264 ar = v.get_result(-1)
265 self.assertEquals(v['a'], 5)
265 self.assertEquals(v['a'], 5)
266 self.assertEquals(v['b'], 24690)
266 self.assertEquals(v['b'], 24690)
267 self.assertRaisesRemote(ZeroDivisionError, ar.get)
267 self.assertRaisesRemote(ZeroDivisionError, ar.get)
268
268
269 def test_autopx_nonblocking(self):
269 def test_autopx_nonblocking(self):
270 ip = get_ipython()
270 ip = get_ipython()
271 v = self.client[-1]
271 v = self.client[-1]
272 v.activate()
272 v.activate()
273 v.block=False
273 v.block=False
274
274
275 with capture_output() as io:
275 with capture_output() as io:
276 ip.magic('autopx')
276 ip.magic('autopx')
277 ip.run_cell('\n'.join(('a=5','b=10','c=0')))
277 ip.run_cell('\n'.join(('a=5','b=10','c=0')))
278 ip.run_cell('print (b)')
278 ip.run_cell('print (b)')
279 ip.run_cell('import time; time.sleep(0.1)')
279 ip.run_cell('import time; time.sleep(0.1)')
280 ip.run_cell("b/c")
280 ip.run_cell("b/c")
281 ip.run_cell('b*=2')
281 ip.run_cell('b*=2')
282 ip.magic('autopx')
282 ip.magic('autopx')
283
283
284 output = io.stdout.rstrip()
284 output = io.stdout.rstrip()
285
285
286 self.assertTrue(output.startswith('%autopx enabled'))
286 self.assertTrue(output.startswith('%autopx enabled'))
287 self.assertTrue(output.endswith('%autopx disabled'))
287 self.assertTrue(output.endswith('%autopx disabled'))
288 self.assertFalse('ZeroDivisionError' in output)
288 self.assertFalse('ZeroDivisionError' in output)
289 ar = v.get_result(-2)
289 ar = v.get_result(-2)
290 self.assertRaisesRemote(ZeroDivisionError, ar.get)
290 self.assertRaisesRemote(ZeroDivisionError, ar.get)
291 # prevent TaskAborted on pulls, due to ZeroDivisionError
291 # prevent TaskAborted on pulls, due to ZeroDivisionError
292 time.sleep(0.5)
292 time.sleep(0.5)
293 self.assertEquals(v['a'], 5)
293 self.assertEquals(v['a'], 5)
294 # b*=2 will not fire, due to abort
294 # b*=2 will not fire, due to abort
295 self.assertEquals(v['b'], 10)
295 self.assertEquals(v['b'], 10)
296
296
297 def test_result(self):
297 def test_result(self):
298 ip = get_ipython()
298 ip = get_ipython()
299 v = self.client[-1]
299 v = self.client[-1]
300 v.activate()
300 v.activate()
301 data = dict(a=111,b=222)
301 data = dict(a=111,b=222)
302 v.push(data, block=True)
302 v.push(data, block=True)
303
303
304 for name in ('a', 'b'):
304 for name in ('a', 'b'):
305 ip.magic('px ' + name)
305 ip.magic('px ' + name)
306 with capture_output() as io:
306 with capture_output() as io:
307 ip.magic('pxresult')
307 ip.magic('pxresult')
308 output = io.stdout
308 output = io.stdout
309 msg = "expected %s output to include %s, but got: %s" % \
309 msg = "expected %s output to include %s, but got: %s" % \
310 ('%pxresult', str(data[name]), output)
310 ('%pxresult', str(data[name]), output)
311 self.assertTrue(str(data[name]) in output, msg)
311 self.assertTrue(str(data[name]) in output, msg)
312
312
313 @dec.skipif_not_matplotlib
313 @dec.skipif_not_matplotlib
314 def test_px_pylab(self):
314 def test_px_pylab(self):
315 """%pylab works on engines"""
315 """%pylab works on engines"""
316 ip = get_ipython()
316 ip = get_ipython()
317 v = self.client[-1]
317 v = self.client[-1]
318 v.block = True
318 v.block = True
319 v.activate()
319 v.activate()
320
320
321 with capture_output() as io:
321 with capture_output() as io:
322 ip.magic("px %pylab inline")
322 ip.magic("px %pylab inline")
323
323
324 self.assertTrue("Welcome to pylab" in io.stdout, io.stdout)
324 self.assertTrue("Welcome to pylab" in io.stdout, io.stdout)
325 self.assertTrue("backend_inline" in io.stdout, io.stdout)
325 self.assertTrue("backend_inline" in io.stdout, io.stdout)
326
326
327 with capture_output() as io:
327 with capture_output() as io:
328 ip.magic("px plot(rand(100))")
328 ip.magic("px plot(rand(100))")
329
329
330 self.assertTrue('Out[' in io.stdout, io.stdout)
330 self.assertTrue('Out[' in io.stdout, io.stdout)
331 self.assertTrue('matplotlib.lines' in io.stdout, io.stdout)
331 self.assertTrue('matplotlib.lines' in io.stdout, io.stdout)
332
332
333 def test_pxconfig(self):
333 def test_pxconfig(self):
334 ip = get_ipython()
334 ip = get_ipython()
335 rc = self.client
335 rc = self.client
336 v = rc.activate(-1, '_tst')
336 v = rc.activate(-1, '_tst')
337 self.assertEquals(v.targets, rc.ids[-1])
337 self.assertEquals(v.targets, rc.ids[-1])
338 ip.magic("%pxconfig_tst -t :")
338 ip.magic("%pxconfig_tst -t :")
339 self.assertEquals(v.targets, rc.ids)
339 self.assertEquals(v.targets, rc.ids)
340 ip.magic("%pxconfig_tst -t ::2")
341 self.assertEquals(v.targets, rc.ids[::2])
342 ip.magic("%pxconfig_tst -t 1::2")
343 self.assertEquals(v.targets, rc.ids[1::2])
344 ip.magic("%pxconfig_tst -t 1")
345 self.assertEquals(v.targets, 1)
340 ip.magic("%pxconfig_tst --block")
346 ip.magic("%pxconfig_tst --block")
341 self.assertEquals(v.block, True)
347 self.assertEquals(v.block, True)
342 ip.magic("%pxconfig_tst --noblock")
348 ip.magic("%pxconfig_tst --noblock")
343 self.assertEquals(v.block, False)
349 self.assertEquals(v.block, False)
344
350
345 def test_cellpx_targets(self):
351 def test_cellpx_targets(self):
346 """%%px --targets doesn't change defaults"""
352 """%%px --targets doesn't change defaults"""
347 ip = get_ipython()
353 ip = get_ipython()
348 rc = self.client
354 rc = self.client
349 view = rc.activate(rc.ids)
355 view = rc.activate(rc.ids)
350 self.assertEquals(view.targets, rc.ids)
356 self.assertEquals(view.targets, rc.ids)
351 for cell in ("pass", "1/0"):
357 for cell in ("pass", "1/0"):
352 with capture_output() as io:
358 with capture_output() as io:
353 try:
359 try:
354 ip.run_cell_magic("px", "--targets all", cell)
360 ip.run_cell_magic("px", "--targets all", cell)
355 except pmod.RemoteError:
361 except pmod.RemoteError:
356 pass
362 pass
357 self.assertTrue('engine(s): all' in io.stdout)
363 self.assertTrue('engine(s): all' in io.stdout)
358 self.assertEquals(view.targets, rc.ids)
364 self.assertEquals(view.targets, rc.ids)
359
365
360
366
361 def test_cellpx_block(self):
367 def test_cellpx_block(self):
362 """%%px --block doesn't change default"""
368 """%%px --block doesn't change default"""
363 ip = get_ipython()
369 ip = get_ipython()
364 rc = self.client
370 rc = self.client
365 view = rc.activate(rc.ids)
371 view = rc.activate(rc.ids)
366 view.block = False
372 view.block = False
367 self.assertEquals(view.targets, rc.ids)
373 self.assertEquals(view.targets, rc.ids)
368 for cell in ("pass", "1/0"):
374 for cell in ("pass", "1/0"):
369 with capture_output() as io:
375 with capture_output() as io:
370 try:
376 try:
371 ip.run_cell_magic("px", "--block", cell)
377 ip.run_cell_magic("px", "--block", cell)
372 except pmod.RemoteError:
378 except pmod.RemoteError:
373 pass
379 pass
374 self.assertFalse('Async' in io.stdout)
380 self.assertFalse('Async' in io.stdout)
375 self.assertFalse(view.block)
381 self.assertFalse(view.block)
376
382
377
383
General Comments 0
You need to be logged in to leave comments. Login now