def get_environment(self): if self._environment is None: if self._environment_path is not None: self._environment = create_environment(self._environment_path, safe=False) else: self._environment = get_cached_default_environment() return self._environment
def script(workspace: Workspace, uri: str) -> Script: """Simplifies getting jedi Script""" project_ = project(workspace) document = workspace.get_document(uri) return Script( code=document.source, path=document.path, project=project_, environment=get_cached_default_environment(), )
def get_environment(self): if self._environment is None: return get_cached_default_environment() return self._environment
def get_environment(self): if self._environment is None: return get_cached_default_environment() return self._environment
def test_changing_venv(venv_path, monkeypatch): monkeypatch.setitem(os.environ, 'VIRTUAL_ENV', venv_path) get_cached_default_environment() monkeypatch.setitem(os.environ, 'VIRTUAL_ENV', sys.executable) assert get_cached_default_environment().executable == sys.executable
def test_changing_venv(venv_path, monkeypatch): monkeypatch.setitem(os.environ, 'VIRTUAL_ENV', venv_path) get_cached_default_environment() monkeypatch.setitem(os.environ, 'VIRTUAL_ENV', sys.executable) assert get_cached_default_environment().executable == sys.executable