mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
49 lines
1.1 KiB
Python
49 lines
1.1 KiB
Python
from textwrap import dedent
|
|
|
|
|
|
def test_in_whitespace(Script):
|
|
code = dedent('''
|
|
def x():
|
|
pass''')
|
|
assert len(Script(code, column=2).completions()) > 20
|
|
|
|
|
|
def test_empty_init(Script):
|
|
"""This was actually an issue."""
|
|
code = dedent('''\
|
|
class X(object): pass
|
|
X(''')
|
|
assert Script(code).completions()
|
|
|
|
|
|
def test_in_empty_space(Script):
|
|
code = dedent('''\
|
|
class X(object):
|
|
def __init__(self):
|
|
hello
|
|
''')
|
|
comps = Script(code, 3, 7).completions()
|
|
self, = [c for c in comps if c.name == 'self']
|
|
assert self.name == 'self'
|
|
def_, = self._goto_definitions()
|
|
assert def_.name == 'X'
|
|
|
|
|
|
def test_indent_context(Script):
|
|
"""
|
|
If an INDENT is the next supposed token, we should still be able to
|
|
complete.
|
|
"""
|
|
code = 'if 1:\nisinstanc'
|
|
comp, = Script(code).completions()
|
|
assert comp.name == 'isinstance'
|
|
|
|
|
|
def test_keyword_context(Script):
|
|
def get_names(*args, **kwargs):
|
|
return [d.name for d in Script(*args, **kwargs).completions()]
|
|
|
|
names = get_names('if 1:\n pass\n')
|
|
assert 'if' in names
|
|
assert 'elif' in names
|