Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
niilohlin committed Jun 5, 2024
1 parent 66fe88d commit e4ec937
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pylsp/hookspecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def pylsp_execute_command(config, workspace, command, arguments):


@hookspec
def pylsp_workspace_symbol(config, workspace, document, query):
def pylsp_workspace_symbol(config, workspace, query):
pass


Expand Down
2 changes: 1 addition & 1 deletion pylsp/plugins/workspace_symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


@hookimpl
def pylsp_workspace_symbol(config, workspace, document, query):
def pylsp_workspace_symbol(config, workspace, query):
if not query or not workspace:
return []

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from pylsp import uris
from pylsp.lsp import SymbolKind
from pylsp.plugins.document_symbols import pylsp_document_symbols
from pylsp.plugins.workspace_symbol import pylsp_workspace_symbol
from pylsp.workspace import Document

PY2 = sys.version[0] == "2"
Expand Down
76 changes: 76 additions & 0 deletions test/plugins/test_workspace_symbols.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Copyright 2017-2020 Palantir Technologies, Inc.
# Copyright 2021- Python Language Server Contributors.

import os
import sys

import pytest

from pylsp import uris
from pylsp.lsp import SymbolKind
from pylsp.plugins.workspace_symbol import pylsp_workspace_symbol
from pylsp.workspace import Workspace

PY2 = sys.version[0] == "2"
LINUX = sys.platform.startswith("linux")
CI = os.environ.get("CI")
DOC_URI = uris.from_fs_path(__file__)
DOC = """import sys
a = 'hello'
class B:
def __init__(self):
x = 2
self.y = x
def main(x):
y = 2 * x
return y
"""


def test_symbols_empty_query(config, workspace):
config.update({"plugins": {"jedi_workspace_symbols": {"enabled": True}}})
symbols = pylsp_workspace_symbol(config, workspace, "")

assert len(symbols) == 0


def test_symbols_nonempty_query(config, workspace):
config.update({"plugins": {"jedi_workspace_symbols": {"enabled": True}}})
symbols = pylsp_workspace_symbol(config, workspace, "main")

assert len(symbols) == 0


#
# def test_symbols_all_scopes(config, workspace):
# doc = Document(DOC_URI, workspace, DOC)
# symbols = pylsp_document_symbols(config, doc)
# helper_check_symbols_all_scope(symbols)
#
#
# def test_symbols_non_existing_file(config, workspace, tmpdir):
# path = tmpdir.join("foo.py")
# # Check pre-condition: file must not exist
# assert not path.check(exists=1)
#
# doc = Document(uris.from_fs_path(str(path)), workspace, DOC)
# symbols = pylsp_document_symbols(config, doc)
# helper_check_symbols_all_scope(symbols)
#
#
# @pytest.mark.skipif(
# PY2 or not LINUX or not CI, reason="tested on linux and python 3 only"
# )
# 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 = {"pylsp": {"plugins": {"jedi": {"environment": env_path}}}}
# doc.update_config(settings)
# symbols = pylsp_document_symbols(doc._config, doc)
# helper_check_symbols_all_scope(symbols)

0 comments on commit e4ec937

Please sign in to comment.