Example #1
0
def test_completion_response():
    """Check completions works."""

    path = abspath('test.py')

    completions = anaconda_mode.complete(
        '''
def test1(a, b):
    """First test function."""
    pass

def test2(c):
    """Second test function."""
    pass

test
''', 10, 4, path)

    assert completions == [{
        "name": "test1",
        "doc": 'test1(a, b)\n\nFirst test function.',
        'info': 'First test function.',
        'type': 'function',
        'path': path,
        'line': 2,
    }, {
        "name": "test2",
        "doc": 'test2(c)\n\nSecond test function.',
        'info': 'Second test function.',
        'type': 'function',
        'path': path,
        'line': 6,
    }]
Example #2
0
def test_completion_response():
    """Check completions works."""

    path = abspath('test.py')

    completions = anaconda_mode.complete('''
def test1(a, b):
    """First test function."""
    pass

def test2(c):
    """Second test function."""
    pass

test
''', 10, 4, path)

    assert completions == [{
        "name": "test1",
        "doc": 'test1(a, b)\n\nFirst test function.',
        'info': 'First test function.',
        'type': 'function',
        'path': path,
        'line': 2,
    }, {
        "name": "test2",
        "doc": 'test2(c)\n\nSecond test function.',
        'info': 'Second test function.',
        'type': 'function',
        'path': path,
        'line': 6,
    }]
def test_completion_response_strip_newlines():
    """Strip newline characters from import statements."""

    path = abspath('test.py')
    source = '''
from sage.rings.all import Integer, PolynomialRing, QuadraticField
Qu
'''
    completions = anaconda_mode.complete(source, 3, 2, path)
    assert 'import: from sage.rings.all import Integer, PolynomialRing, QuadraticField' == completions[0]['description']
def test_completion_response_strip_newlines():
    """Strip newline characters from import statements."""

    path = abspath('test.py')
    source = '''
from sage.rings.all import Integer, PolynomialRing, QuadraticField
Qu
'''
    completions = anaconda_mode.complete(source, 3, 2, path)
    assert 'import: from sage.rings.all import Integer, PolynomialRing, QuadraticField' == completions[
        0]['description']
Example #5
0
def test_completion_response():
    """Check completions works."""

    path = abspath('test.py')

    completions = anaconda_mode.complete('''
def test1(a, b):
    """First test function."""
    pass

def test2(c):
    """Second test function."""
    pass

test
''', 10, 4, path)

    assert 'test1' == completions[0]['name']
    assert 'test2' == completions[1]['name']
Example #6
0
def test_completion_response():
    """Check completions works."""

    path = abspath("test.py")

    completions = anaconda_mode.complete(
        '''
def test1(a, b):
    """First test function."""
    pass

def test2(c):
    """Second test function."""
    pass

test
''',
        10,
        4,
        path,
    )

    assert "test1" == completions[0]["name"]
    assert "test2" == completions[1]["name"]