def test_jedi_completion_extra_paths(config, tmpdir, workspace): # Create a tempfile with some content and pass to extra_paths temp_doc_content = ''' def spam(): pass ''' p = tmpdir.mkdir("extra_path") extra_paths = [str(p)] p = p.join("foo.py") p.write(temp_doc_content) # Content of doc to test completion doc_content = """import foo foo.s""" doc = Document(DOC_URI, workspace, doc_content) # After 'foo.s' without extra paths com_position = {'line': 1, 'character': 5} completions = pyls_jedi_completions(config, doc, com_position) assert completions is None # Update config extra paths config.update({'plugins': {'jedi': {'extra_paths': extra_paths}}}) doc.update_config(config) # After 'foo.s' with extra paths com_position = {'line': 1, 'character': 5} completions = pyls_jedi_completions(config, doc, com_position) assert completions[0]['label'] == 'spam()'
def test_jedi_completion_environment(config): # Content of doc to test completion doc_content = '''import logh ''' doc = Document(DOC_URI, MockWorkspace(), doc_content) # After 'import logh' with default environment com_position = {'line': 0, 'character': 11} assert os.path.isdir('/tmp/pyenv/') config.update({'plugins': {'jedi': {'environment': None}}}) doc.update_config(config) completions = pyls_jedi_completions(config, doc, com_position) assert completions is None # Update config extra environment env_path = '/tmp/pyenv/bin/python' config.update({'plugins': {'jedi': {'environment': env_path}}}) doc.update_config(config) # After 'import logh' with new environment completions = pyls_jedi_completions(config, doc, com_position) assert completions[0]['label'] == 'loghub' assert 'changelog generator' in completions[0]['documentation'].lower()
def test_symbols_all_scopes_with_jedi_environment(config): doc = Document(DOC_URI, MockWorkspace(), DOC) # Update config extra environment env_path = '/tmp/pyenv/bin/python' config.update({'plugins': {'jedi': {'environment': env_path}}}) doc.update_config(config) symbols = pyls_document_symbols(config, doc) helper_check_symbols_all_scope(symbols)
def test_symbols_all_scopes_with_jedi_environment(workspace): doc = Document(DOC_URI, workspace, DOC) # Update config extra environment env_path = '/tmp/pyenv/bin/python' settings = {'pyls': {'plugins': {'jedi': {'environment': env_path}}}} doc.update_config(settings) symbols = pyls_document_symbols(doc._config, doc) helper_check_symbols_all_scope(symbols)