コード例 #1
0
    def _get_envs(self):
        """Get the list of environments in the system."""
        # Compute info of default interpreter to have it available in
        # case we need to switch to it. This will avoid lags when
        # doing that in get_value.
        if sys.executable not in self.path_to_env:
            self._get_env_info(sys.executable)

        # Get envs
        conda_env = get_list_conda_envs()
        pyenv_env = get_list_pyenv_envs()
        return {**conda_env, **pyenv_env}
コード例 #2
0
ファイル: test_pyenv.py プロジェクト: hlouzada/spyder
def test_get_list_pyenv_envs():
    output = get_list_pyenv_envs()
    expected_envs = ['pyenv: 3.8.1']
    assert set(expected_envs) == set(output.keys())
コード例 #3
0
ファイル: test_confpage.py プロジェクト: hlouzada/spyder
from spyder.api.plugins import Plugins
from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY
from spyder.config.manager import CONF
from spyder.plugins.preferences.api import PreferencePages
from spyder.plugins.maininterpreter.plugin import MainInterpreter
from spyder.plugins.preferences.tests.conftest import MainWindowMock
from spyder.utils.conda import get_list_conda_envs
from spyder.utils.pyenv import get_list_pyenv_envs

# Get envs to show them in the Main interpreter page. This is actually
# done in a thread in the InterpreterStatus widget.
# We also recording the time needed to get them to compare it with the
# loading time of that config page.
t0 = time.time()
get_list_conda_envs()
get_list_pyenv_envs()
GET_ENVS_TIME = time.time() - t0


def test_load_time(qtbot):
    from spyder.plugins.maininterpreter.confpage import (
        MainInterpreterConfigPage)

    # Create Preferences dialog
    main = MainWindowMock()
    preferences = main.get_plugin(Plugins.Preferences)

    main_interpreter = PLUGIN_REGISTRY.register_plugin(main, MainInterpreter)

    # Create page and measure time to do it
    t0 = time.time()
コード例 #4
0
# Local imports
from spyder.api.plugins import Plugins
from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY
from spyder.plugins.maininterpreter.plugin import MainInterpreter
from spyder.plugins.preferences.tests.conftest import MainWindowMock
from spyder.utils.conda import get_list_conda_envs
from spyder.utils.pyenv import get_list_pyenv_envs

# Get envs to show them in the Main interpreter page. This is actually
# done in a thread in the InterpreterStatus widget.
# We're also recording the time needed to get them to compare it with the
# loading time of that config page.
t0 = time.time()
conda_envs = get_list_conda_envs()
pyenv_envs = get_list_pyenv_envs()
GET_ENVS_TIME = time.time() - t0


@pytest.mark.skipif(
    len(conda_envs) == 0 and len(pyenv_envs) == 0,
    reason="Makes no sense if conda and pyenv are not installed")
def test_load_time(qtbot):
    # Create Preferences dialog
    main = MainWindowMock(None)
    preferences = main.get_plugin(Plugins.Preferences)

    PLUGIN_REGISTRY.register_plugin(main, MainInterpreter)

    # Create page and measure time to do it
    t0 = time.time()