Esempio n. 1
0
    def close_rope_project(self):
        """Close the Rope project"""
        if self.project is not None:
            self.project.close()


if __name__ == '__main__':

    from spyderlib.utils.introspection.plugin_manager import CodeInfo

    p = RopePlugin()
    p.load_plugin()

    source_code = "import numpy; numpy.ones"
    docs = p.get_info(CodeInfo('info', source_code, len(source_code),
                                           __file__))
    assert 'ones(' in docs['calltip'] and 'ones(' in docs['docstring']

    source_code = "import numpy; n"
    completions = p.get_completions(CodeInfo('completions', source_code,
        len(source_code), __file__))
    assert ('numpy', 'module') in completions

    source_code = "import pandas as pd; pd.DataFrame"
    path, line_nr = p.get_definition(CodeInfo('definition', source_code,
        len(source_code), __file__))
    assert 'frame.py' in path

    code = '''
def test(a, b):
    """Test docstring"""
Esempio n. 2
0
    def close_rope_project(self):
        """Close the Rope project"""
        if self.project is not None:
            self.project.close()


if __name__ == '__main__':

    from spyderlib.utils.introspection.plugin_manager import CodeInfo

    p = RopePlugin()
    p.load_plugin()

    source_code = "import numpy; numpy.ones"
    docs = p.get_info(CodeInfo('info', source_code, len(source_code),
                               __file__))
    assert 'ones(' in docs['calltip'] and 'ones(' in docs['docstring']

    source_code = "import numpy; n"
    completions = p.get_completions(
        CodeInfo('completions', source_code, len(source_code), __file__))
    assert 'numpy' in completions

    source_code = "import matplotlib.pyplot as plt; plt.imsave"
    path, line_nr = p.get_definition(
        CodeInfo('definition', source_code, len(source_code), __file__))
    assert 'pyplot.py' in path

    code = '''
def test(a, b):
    """Test docstring"""
Esempio n. 3
0
    if os.path.isdir(path):
        return [p for p in _listdir(path)]
    # exact file match terminates this completion
    return [path + ' ']


if __name__ == '__main__':
    from spyderlib.utils.introspection.plugin_manager import CodeInfo

    p = FallbackPlugin()

    with open(__file__, 'rb') as fid:
        code = fid.read().decode('utf-8')
    code += '\nlog_dt'

    path, line = p.get_definition(CodeInfo('definition', code, len(code),
        __file__))
    assert path.endswith('fallback_plugin.py')

    code += '\np.get_completions'
    path, line = p.get_definition(CodeInfo('definition', code, len(code),
        'dummy.txt'))
    assert path == 'dummy.txt'
    assert 'def get_completions(' in code.splitlines()[line - 1]

    code += '\npython_like_mod_finder'
    path, line = p.get_definition(CodeInfo('definition', code, len(code),
        'dummy.txt'))
    assert path == 'dummy.txt'
    # FIXME: we need to prioritize def over =
    assert 'def python_like_mod_finder' in code.splitlines()[line - 1]