1
0
forked from VimPlug/jedi

Allow access to all the Jedi methods with a simplified interface in regression tests

This commit is contained in:
David Halter
2013-08-07 12:54:43 +04:30
parent c6e08221ce
commit 03c75babdd

View File

@@ -18,27 +18,21 @@ sample_int = 1 # This is used in completion/imports.py
class TestBase(unittest.TestCase): class TestBase(unittest.TestCase):
def get_script(self, src, pos, path=None): def get_script(self, src, pos=None, path=None):
if pos is None: if pos is None:
lines = src.splitlines() lines = src.splitlines()
pos = len(lines), len(lines[-1]) pos = len(lines), len(lines[-1])
return jedi.Script(src, pos[0], pos[1], path) return jedi.Script(src, pos[0], pos[1], path)
def goto_definitions(self, src, pos=None): def __getattr__(self, name):
script = self.get_script(src, pos) """Allow access to all the Jedi methods with a simplified interface."""
return script.goto_definitions() if not hasattr(jedi.Script, name):
raise AttributeError("Don't use getattr on this without Jedi methods")
def completions(self, src, pos=None, path=None): def action(*args, **kwargs):
script = self.get_script(src, pos, path) print args, kwargs
return script.completions() script = self.get_script(*args, **kwargs)
return getattr(script, name)()
def goto_assignments(self, src, pos=None): return action
script = self.get_script(src, pos)
return script.goto_assignments()
def function_definition(self, src, pos=None):
script = self.get_script(src, pos)
return script.function_definition()
def cwd_at(path): def cwd_at(path):