added additional_dynamic_modules setting

This commit is contained in:
David Halter
2012-09-26 18:19:41 +02:00
parent bb42a351e0
commit 908d019390
4 changed files with 36 additions and 13 deletions

View File

@@ -18,7 +18,9 @@ class TestRegression(unittest.TestCase):
script = api.Script(src, pos[0], pos[1], '')
return script.get_definition()
def complete(self, src, pos):
def complete(self, src, pos=None):
if pos is None:
pos = 1, len(src)
script = api.Script(src, pos[0], pos[1], '')
return script.complete()
@@ -152,5 +154,19 @@ class TestRegression(unittest.TestCase):
assert check(self.get_in_function_call(s7), 'center', 0)
def test_add_dynamic_mods(self):
api.settings.additional_dynamic_modules = ['dynamic.py']
# Fictional module that defines a function.
src1 = "def ret(a): return a"
# Other fictional modules in another place in the fs.
src2 = 'from .. import setup; setup.ret(1)'
# .parser to load the module
api.modules.Module(os.path.abspath('dynamic.py'), src2).parser
script = api.Script(src1, 1, len(src1), '../setup.py')
result = script.get_definition()
assert len(result) == 1
assert result[0].description == 'class int'
if __name__ == '__main__':
unittest.main()