fix add_bracket_after_function had no effect (#1297)

* fix add_bracket_after_function had no effect

* added test for fix

* using monkeypatch to set add_bracket_after_function.
This commit is contained in:
Andreas Mittelberger
2019-04-12 15:41:02 -07:00
committed by Dave Halter
parent c801e24afc
commit e843c6108d
2 changed files with 12 additions and 1 deletions

View File

@@ -397,7 +397,7 @@ class Completion(BaseDefinition):
def _complete(self, like_name): def _complete(self, like_name):
append = '' append = ''
if settings.add_bracket_after_function \ if settings.add_bracket_after_function \
and self.type == 'Function': and self.type == 'function':
append = '(' append = '('
if self._name.api_type == 'param' and self._stack is not None: if self._name.api_type == 'param' and self._stack is not None:

View File

@@ -21,3 +21,14 @@ def test_add_dynamic_mods(Script):
result = script.goto_definitions() result = script.goto_definitions()
assert len(result) == 1 assert len(result) == 1
assert result[0].description == 'class int' assert result[0].description == 'class int'
def test_add_bracket_after_function(monkeypatch, Script):
settings = api.settings
monkeypatch.setattr(settings, 'add_bracket_after_function', True)
script = Script('''\
def foo():
pass
foo''')
completions = script.completions()
assert completions[0].complete == '('