forked from VimPlug/jedi
Allow access to all the Jedi methods with a simplified interface in regression tests
This commit is contained in:
26
test/base.py
26
test/base.py
@@ -18,27 +18,21 @@ sample_int = 1 # This is used in completion/imports.py
|
||||
|
||||
|
||||
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:
|
||||
lines = src.splitlines()
|
||||
pos = len(lines), len(lines[-1])
|
||||
return jedi.Script(src, pos[0], pos[1], path)
|
||||
|
||||
def goto_definitions(self, src, pos=None):
|
||||
script = self.get_script(src, pos)
|
||||
return script.goto_definitions()
|
||||
|
||||
def completions(self, src, pos=None, path=None):
|
||||
script = self.get_script(src, pos, path)
|
||||
return script.completions()
|
||||
|
||||
def goto_assignments(self, src, pos=None):
|
||||
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 __getattr__(self, name):
|
||||
"""Allow access to all the Jedi methods with a simplified interface."""
|
||||
if not hasattr(jedi.Script, name):
|
||||
raise AttributeError("Don't use getattr on this without Jedi methods")
|
||||
def action(*args, **kwargs):
|
||||
print args, kwargs
|
||||
script = self.get_script(*args, **kwargs)
|
||||
return getattr(script, name)()
|
||||
return action
|
||||
|
||||
|
||||
def cwd_at(path):
|
||||
|
||||
Reference in New Issue
Block a user