##// END OF EJS Templates
update parallel magics tests with 2.7 APIs
MinRK -
Show More
@@ -69,14 +69,14 b' class TestParallelMagics(ClusterTestCase, ParametricTestCase):'
69 '^stderr2$',
69 '^stderr2$',
70 ] * n
70 ] * n
71
71
72 self.assertFalse('\n\n' in stderr, stderr)
72 self.assertNotIn('\n\n', stderr)
73 lines = stderr.splitlines()
73 lines = stderr.splitlines()
74 self.assertEqual(len(lines), len(expected), stderr)
74 self.assertEqual(len(lines), len(expected), stderr)
75 for line,expect in zip(lines, expected):
75 for line,expect in zip(lines, expected):
76 if isinstance(expect, str):
76 if isinstance(expect, str):
77 expect = [expect]
77 expect = [expect]
78 for ex in expect:
78 for ex in expect:
79 self.assertTrue(re.search(ex, line) is not None, "Expected %r in %r" % (ex, line))
79 assert re.search(ex, line) is not None, "Expected %r in %r" % (ex, line)
80
80
81 def test_cellpx_block_args(self):
81 def test_cellpx_block_args(self):
82 """%%px --[no]block flags work"""
82 """%%px --[no]block flags work"""
@@ -132,7 +132,7 b' class TestParallelMagics(ClusterTestCase, ParametricTestCase):'
132 if isinstance(expect, str):
132 if isinstance(expect, str):
133 expect = [expect]
133 expect = [expect]
134 for ex in expect:
134 for ex in expect:
135 self.assertTrue(re.search(ex, line) is not None, "Expected %r in %r" % (ex, line))
135 assert re.search(ex, line) is not None, "Expected %r in %r" % (ex, line)
136
136
137 self._check_generated_stderr(io.stderr, len(v))
137 self._check_generated_stderr(io.stderr, len(v))
138
138
@@ -174,7 +174,7 b' class TestParallelMagics(ClusterTestCase, ParametricTestCase):'
174 if isinstance(expect, str):
174 if isinstance(expect, str):
175 expect = [expect]
175 expect = [expect]
176 for ex in expect:
176 for ex in expect:
177 self.assertTrue(re.search(ex, line) is not None, "Expected %r in %r" % (ex, line))
177 assert re.search(ex, line) is not None, "Expected %r in %r" % (ex, line)
178
178
179 self._check_generated_stderr(io.stderr, len(v))
179 self._check_generated_stderr(io.stderr, len(v))
180
180
@@ -213,7 +213,7 b' class TestParallelMagics(ClusterTestCase, ParametricTestCase):'
213 if isinstance(expect, str):
213 if isinstance(expect, str):
214 expect = [expect]
214 expect = [expect]
215 for ex in expect:
215 for ex in expect:
216 self.assertTrue(re.search(ex, line) is not None, "Expected %r in %r" % (ex, line))
216 assert re.search(ex, line) is not None, "Expected %r in %r" % (ex, line)
217
217
218 self._check_generated_stderr(io.stderr, len(v))
218 self._check_generated_stderr(io.stderr, len(v))
219
219
@@ -231,10 +231,10 b' class TestParallelMagics(ClusterTestCase, ParametricTestCase):'
231 ip.magic('pxconfig --verbose')
231 ip.magic('pxconfig --verbose')
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.assertIsInstance(ar, AsyncResult)
235 self.assertTrue('Async' in io.stdout)
235 self.assertIn('Async', io.stdout)
236 self.assertFalse('[stdout:' in io.stdout)
236 self.assertNotIn('[stdout:', io.stdout)
237 self.assertFalse('\n\n' in io.stdout)
237 self.assertNotIn('\n\n', 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)
@@ -256,11 +256,11 b' class TestParallelMagics(ClusterTestCase, ParametricTestCase):'
256
256
257 output = io.stdout
257 output = io.stdout
258
258
259 self.assertTrue(output.startswith('%autopx enabled'), output)
259 assert output.startswith('%autopx enabled'), output
260 self.assertTrue(output.rstrip().endswith('%autopx disabled'), output)
260 assert output.rstrip().endswith('%autopx disabled'), output
261 self.assertTrue('ZeroDivisionError' in output, output)
261 self.assertIn('ZeroDivisionError', output)
262 self.assertTrue('\nOut[' in output, output)
262 self.assertIn('\nOut[', output)
263 self.assertTrue(': 24690' in output, output)
263 self.assertIn(': 24690', output)
264 ar = v.get_result(-1)
264 ar = v.get_result(-1)
265 self.assertEqual(v['a'], 5)
265 self.assertEqual(v['a'], 5)
266 self.assertEqual(v['b'], 24690)
266 self.assertEqual(v['b'], 24690)
@@ -283,9 +283,9 b' class TestParallelMagics(ClusterTestCase, ParametricTestCase):'
283
283
284 output = io.stdout.rstrip()
284 output = io.stdout.rstrip()
285
285
286 self.assertTrue(output.startswith('%autopx enabled'))
286 assert output.startswith('%autopx enabled'), output
287 self.assertTrue(output.endswith('%autopx disabled'))
287 assert output.endswith('%autopx disabled'), output
288 self.assertFalse('ZeroDivisionError' in output)
288 self.assertNotIn('ZeroDivisionError', 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
General Comments 0
You need to be logged in to leave comments. Login now