##// END OF EJS Templates
re-enable pydb flag...
re-enable pydb flag Note that pydb has been deprecated, and superseded by pydbgr, which may be abandoned. It would be preferable if the Pdb class could inherit from pydb or pdb based on a runtime flag rather than checking sys.argv at the top level. This at least restores old behavior for pydb users. closes #636

File last commit:

r4155:a82262e5
r5004:d16b38ed
Show More
test_asyncresult.py
73 lines | 2.2 KiB | text/x-python | PythonLexer
MinRK
update recently changed modules with Authors in docstring
r4018 """Tests for asyncresult.py
Authors:
* Min RK
"""
MinRK
update API after sagedays29...
r3664
#-------------------------------------------------------------------------------
# Copyright (C) 2011 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# Imports
#-------------------------------------------------------------------------------
MinRK
move IPython.zmq.parallel to IPython.parallel
r3666 from IPython.parallel.error import TimeoutError
MinRK
update API after sagedays29...
r3664
MinRK
move IPython.zmq.parallel to IPython.parallel
r3666 from IPython.parallel.tests import add_engines
MinRK
update API after sagedays29...
r3664 from .clienttest import ClusterTestCase
def setup():
add_engines(2)
def wait(n):
import time
time.sleep(n)
return n
class AsyncResultTest(ClusterTestCase):
def test_single_result(self):
eid = self.client.ids[-1]
ar = self.client[eid].apply_async(lambda : 42)
self.assertEquals(ar.get(), 42)
ar = self.client[[eid]].apply_async(lambda : 42)
self.assertEquals(ar.get(), [42])
ar = self.client[-1:].apply_async(lambda : 42)
self.assertEquals(ar.get(), [42])
def test_get_after_done(self):
ar = self.client[-1].apply_async(lambda : 42)
ar.wait()
self.assertTrue(ar.ready())
self.assertEquals(ar.get(), 42)
self.assertEquals(ar.get(), 42)
def test_get_before_done(self):
ar = self.client[-1].apply_async(wait, 0.1)
self.assertRaises(TimeoutError, ar.get, 0)
ar.wait(0)
self.assertFalse(ar.ready())
self.assertEquals(ar.get(), 0.1)
def test_get_after_error(self):
ar = self.client[-1].apply_async(lambda : 1/0)
MinRK
update parallel code for py3k...
r4155 ar.wait(10)
MinRK
update API after sagedays29...
r3664 self.assertRaisesRemote(ZeroDivisionError, ar.get)
self.assertRaisesRemote(ZeroDivisionError, ar.get)
self.assertRaisesRemote(ZeroDivisionError, ar.get_dict)
def test_get_dict(self):
n = len(self.client)
ar = self.client[:].apply_async(lambda : 5)
self.assertEquals(ar.get(), [5]*n)
d = ar.get_dict()
self.assertEquals(sorted(d.keys()), sorted(self.client.ids))
for eid,r in d.iteritems():
self.assertEquals(r, 5)