| 1 |
from textwrap import dedent |
| 2 |
|
| 3 |
|
| 4 |
def test_error_correction_with(Script): |
| 5 |
source = """ |
| 6 |
with open() as f: |
| 7 |
try: |
| 8 |
f.""" |
| 9 |
comps = Script(source).complete() |
| 10 |
assert len(comps) > 30 |
| 11 |
|
| 12 |
assert [1 for c in comps if c.name == 'closed'] |
| 13 |
|
| 14 |
|
| 15 |
def test_string_literals(Script): |
| 16 |
"""Simplified case of jedi-vim#377.""" |
| 17 |
source = dedent(""" |
| 18 |
x = ur''' |
| 19 |
|
| 20 |
def foo(): |
| 21 |
pass |
| 22 |
""") |
| 23 |
|
| 24 |
script = Script(dedent(source)) |
| 25 |
assert script._get_module_context().tree_node.end_pos == (6, 0) |
| 26 |
assert not script.complete() |
| 27 |
|
| 28 |
|
| 29 |
def test_incomplete_function(Script): |
| 30 |
source = '''return ImportErr''' |
| 31 |
|
| 32 |
script = Script(dedent(source)) |
| 33 |
assert script.complete(1, 3) |
| 34 |
|
| 35 |
|
| 36 |
def test_decorator_string_issue(Script): |
| 37 |
""" |
| 38 |
Test case from #589 |
| 39 |
""" |
| 40 |
source = dedent('''\ |
| 41 |
""" |
| 42 |
@""" |
| 43 |
def bla(): |
| 44 |
pass |
| 45 |
|
| 46 |
bla.''') |
| 47 |
|
| 48 |
s = Script(source) |
| 49 |
assert s.complete() |
| 50 |
assert s._get_module_context().tree_node.get_code() == source |