##// END OF EJS Templates
Improve tooltip tringgering,make it configurable...
Improve tooltip tringgering,make it configurable As until now, when pressing tab and a white space was preceding the cursor The completion was triggerd with the whole namespace in it. Now if a whitespace or an opening bracket is just befor the cursor it will try to display a tooltip. The logic to find what object_info_request is send have been sightly changed to try to match the expression just before the last unmached openig bracket before the cursor (without considering what is after the cursor). example (_|_ represent the cursor): >>> his_|_<tab> # completion >>> hist(_|_<tab> # tooltip on hist >>> hist(rand(20),bins=range(_|_ <tab> #tooltip on range >>> hist(rand(20),bins=range(10), _|_ <tab> # tooltip on hist (whitespace before cursor) >>> hist(rand(20),bins=range(10),_|_ <tab> # completion as we dont care of what is after the cursor: >>> hist(rand(5000), bins=50, _|_orientaion='horizontal') # and tab, equivalent to >>> hist(rand(5000), bins=50, _|_<tab> # onte the space again >>> hist(_|_rand(5000), bins=50, orientaion='horizontal') # and tab, equivalent to >>> hist(_|_ the 4 give tooltip on hist note that you can get tooltip on things that aren't function by appending a '(' like >>> matplotlib(<tab> Which is kinda weird... so we might want to bound another shortcut for tooltip, but which matches without bracket... additionnaly I have added a "Config" pannel in the left pannel with a checkbox bind to wether or not activate this functionnality Note, (rebase and edited commit, might not work perfetly xwithout the following ones)

File last commit:

r5222:d1c1aaa7
r5399:f73c6ce0
Show More
test_asyncresult.py
115 lines | 4.1 KiB | text/x-python | PythonLexer
"""Tests for asyncresult.py
Authors:
* Min RK
"""
#-------------------------------------------------------------------------------
# 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
#-------------------------------------------------------------------------------
from IPython.parallel.error import TimeoutError
from IPython.parallel.tests import add_engines
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)
ar.wait(10)
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)
def test_list_amr(self):
ar = self.client.load_balanced_view().map_async(wait, [0.1]*5)
rlist = list(ar)
def test_getattr(self):
ar = self.client[:].apply_async(wait, 0.5)
self.assertRaises(AttributeError, lambda : ar._foo)
self.assertRaises(AttributeError, lambda : ar.__length_hint__())
self.assertRaises(AttributeError, lambda : ar.foo)
self.assertRaises(AttributeError, lambda : ar.engine_id)
self.assertFalse(hasattr(ar, '__length_hint__'))
self.assertFalse(hasattr(ar, 'foo'))
self.assertFalse(hasattr(ar, 'engine_id'))
ar.get(5)
self.assertRaises(AttributeError, lambda : ar._foo)
self.assertRaises(AttributeError, lambda : ar.__length_hint__())
self.assertRaises(AttributeError, lambda : ar.foo)
self.assertTrue(isinstance(ar.engine_id, list))
self.assertEquals(ar.engine_id, ar['engine_id'])
self.assertFalse(hasattr(ar, '__length_hint__'))
self.assertFalse(hasattr(ar, 'foo'))
self.assertTrue(hasattr(ar, 'engine_id'))
def test_getitem(self):
ar = self.client[:].apply_async(wait, 0.5)
self.assertRaises(TimeoutError, lambda : ar['foo'])
self.assertRaises(TimeoutError, lambda : ar['engine_id'])
ar.get(5)
self.assertRaises(KeyError, lambda : ar['foo'])
self.assertTrue(isinstance(ar['engine_id'], list))
self.assertEquals(ar.engine_id, ar['engine_id'])
def test_single_result(self):
ar = self.client[-1].apply_async(wait, 0.5)
self.assertRaises(TimeoutError, lambda : ar['foo'])
self.assertRaises(TimeoutError, lambda : ar['engine_id'])
self.assertTrue(ar.get(5) == 0.5)
self.assertTrue(isinstance(ar['engine_id'], int))
self.assertTrue(isinstance(ar.engine_id, int))
self.assertEquals(ar.engine_id, ar['engine_id'])