File: test_error_correction.py

package info (click to toggle)
python-jedi 0.19.1%2Bds1-1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,680 kB
  • sloc: python: 28,783; makefile: 172; ansic: 13
file content (50 lines) | stat: -rw-r--r-- 1,027 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from textwrap import dedent


def test_error_correction_with(Script):
    source = """
    with open() as f:
        try:
            f."""
    comps = Script(source).complete()
    assert len(comps) > 30
    # `open` completions have a closed attribute.
    assert [1 for c in comps if c.name == 'closed']


def test_string_literals(Script):
    """Simplified case of jedi-vim#377."""
    source = dedent("""
    x = ur'''

    def foo():
        pass
    """)

    script = Script(dedent(source))
    assert script._get_module_context().tree_node.end_pos == (6, 0)
    assert not script.complete()


def test_incomplete_function(Script):
    source = '''return ImportErr'''

    script = Script(dedent(source))
    assert script.complete(1, 3)


def test_decorator_string_issue(Script):
    """
    Test case from #589
    """
    source = dedent('''\
    """
      @"""
    def bla():
      pass

    bla.''')

    s = Script(source)
    assert s.complete()
    assert s._get_module_context().tree_node.get_code() == source