Add a few tests about simple completions for interpreters

This commit is contained in:
Dave Halter
2019-06-06 00:17:37 +02:00
parent de03b96232
commit 84eb91beaa
2 changed files with 27 additions and 0 deletions

View File

@@ -202,6 +202,8 @@ def _create(evaluator, access_handle, parent_context, *args):
)
result = _find_syntax_node_name(evaluator, access_handle)
# TODO use stub contexts here. If we do that we probably have to care about
# generics from stuff like `[1]`.
if result is None:
return compiled_object

View File

@@ -368,3 +368,28 @@ def test_sys_path_docstring(): # Was an issue in #1298
import jedi
s = jedi.Interpreter("from sys import path\npath", line=2, column=4, namespaces=[locals()])
s.completions()[0].docstring()
@pytest.mark.parametrize(
'code, completions', [
('x[0].uppe', ['upper']),
('x[1337].uppe', ['upper']),
('x[""].uppe', ['upper']),
('x.appen', ['append']),
('y.add', ['add']),
('y[0].', []),
('list(y)[0].', []), # TODO use stubs properly to improve this.
('z[0].uppe', ['upper']),
('z[0].append', ['append']),
('z[1].uppe', ['upper']),
('z[1].append', []),
]
)
def test_simple_completions(code, completions):
x = [str]
y = {1}
z = {1: str, 2: list}
defs = jedi.Interpreter(code, [locals()]).completions()
assert [d.name for d in defs] == completions