Skip to content

Commit

Permalink
Revert "Allow to use custom python interpreter [fixes palantir#339]"
Browse files Browse the repository at this point in the history
This reverts commit 119c831.
  • Loading branch information
st4lk committed Sep 11, 2018
1 parent 6164ef0 commit 0b05bb0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 36 deletions.
7 changes: 2 additions & 5 deletions pyls/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ class Workspace(object):
M_APPLY_EDIT = 'workspace/applyEdit'
M_SHOW_MESSAGE = 'window/showMessage'

def __init__(self, root_uri, endpoint, config=None):
self._config = config
def __init__(self, root_uri, endpoint):
self._root_uri = root_uri
self._endpoint = endpoint
self._root_uri_scheme = uris.urlparse(self._root_uri)[0]
Expand Down Expand Up @@ -98,13 +97,12 @@ def _create_document(self, doc_uri, source=None, version=None):
doc_uri, source=source, version=version,
extra_sys_path=self.source_roots(path),
rope_project_builder=self._rope_project_builder,
config=self._config,
)


class Document(object):

def __init__(self, uri, source=None, version=None, local=True, extra_sys_path=None, rope_project_builder=None, config=None):
def __init__(self, uri, source=None, version=None, local=True, extra_sys_path=None, rope_project_builder=None):
self.uri = uri
self.version = version
self.path = uris.to_fs_path(uri)
Expand All @@ -114,7 +112,6 @@ def __init__(self, uri, source=None, version=None, local=True, extra_sys_path=No
self._source = source
self._extra_sys_path = extra_sys_path or []
self._rope_project_builder = rope_project_builder
self._config = config

def __str__(self):
return str(self.uri)
Expand Down
3 changes: 1 addition & 2 deletions test/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ def pyls(tmpdir):
@pytest.fixture
def workspace(tmpdir):
"""Return a workspace."""
root_uri = uris.from_fs_path(str(tmpdir))
return Workspace(root_uri, Mock(), Config(root_uri, {}))
return Workspace(uris.from_fs_path(str(tmpdir)), Mock())


@pytest.fixture
Expand Down
29 changes: 0 additions & 29 deletions test/test_document.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# Copyright 2017 Palantir Technologies, Inc.
import jedi
import mock

from test.fixtures import DOC_URI, DOC
from pyls.workspace import Document

Expand Down Expand Up @@ -100,29 +97,3 @@ def test_document_end_of_file_edit():
"print 'b'\n",
"o",
]


def test_sys_path_python_virtualenv(config, monkeypatch):
config.update({"python_virtualenv": '/path/to/virtualenv/'})
doc = Document(DOC_URI, DOC, config=config)
get_sys_path_mock = mock.Mock(return_value=['/new/sys/path'])
mocked = mock.Mock(return_value=mock.Mock(get_sys_path=get_sys_path_mock))
with monkeypatch.context():
monkeypatch.setattr(jedi.api.environment, 'create_environment', mocked)
sys_path = doc.sys_path()
assert mocked.call_count == 1
assert '/path/to/virtualenv/' in mocked.call_args[0]
assert '/new/sys/path' in sys_path


def test_sys_path_python_interpreter(config, monkeypatch):
config.update({"python_interpreter": '/path/to/virtualenv/bin/python'})
doc = Document(DOC_URI, DOC, config=config)
env_mock = mock.Mock(return_value=['/new/sys/path'])
mocked = mock.Mock(return_value=mock.Mock(get_sys_path=env_mock))
with monkeypatch.context():
monkeypatch.setattr(jedi.api.environment, 'Environment', mocked)
sys_path = doc.sys_path()
assert mocked.call_count == 1
assert '/path/to/virtualenv/bin/python' in mocked.call_args[0]
assert '/new/sys/path' in sys_path

0 comments on commit 0b05bb0

Please sign in to comment.