From 03c75babddc8da3142646f7970e538d2b1eb916e Mon Sep 17 00:00:00 2001 From: David Halter Date: Wed, 7 Aug 2013 12:54:43 +0430 Subject: [PATCH] Allow access to all the Jedi methods with a simplified interface in regression tests --- test/base.py | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/test/base.py b/test/base.py index 548e4cfe..39b48162 100644 --- a/test/base.py +++ b/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):