From 605b30e917c7669b92239c00e56772be58e809bd Mon Sep 17 00:00:00 2001 From: dalthviz Date: Tue, 14 Feb 2023 14:09:41 -0500 Subject: [PATCH 01/14] Update CI and requirements for Spyder 6 --- .github/workflows/linux-tests.yml | 4 ++++ requirements/conda.txt | 3 ++- setup.py | 5 +++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/linux-tests.yml b/.github/workflows/linux-tests.yml index 36c6e0d..e7dc968 100644 --- a/.github/workflows/linux-tests.yml +++ b/.github/workflows/linux-tests.yml @@ -49,6 +49,10 @@ jobs: run: | pip install -r requirements/conda.txt pip install -r requirements/tests.txt + - name: Install Spyder from master branch (Future Spyder 6) + shell: bash -l {0} + run: | + pip install git+https://github.com/spyder-ide/spyder.git@master - name: Install Package shell: bash -l {0} run: pip install --no-deps -e . diff --git a/requirements/conda.txt b/requirements/conda.txt index 48ab5cd..2ad92db 100644 --- a/requirements/conda.txt +++ b/requirements/conda.txt @@ -2,4 +2,5 @@ envs-manager>=0.1.2 qtawesome qtpy setuptools -spyder>=5.4.2 +# Uncomment when Spyder 6 is available +# spyder>=6 diff --git a/setup.py b/setup.py index 9ea6c58..6d14142 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ version=__version__, author="Spyder Development Team and spyder-env-manager contributors", author_email="spyder.python@gmail.com", - description="Spyder 5+ plugin to manage Python virtual environments and packages", + description="Spyder 6+ plugin to manage Python virtual environments and packages", license="MIT license", url="https://github.com/spyder-ide/spyder-env-manager", python_requires=">= 3.7", @@ -25,7 +25,8 @@ "envs-manager>=0.1.1", "qtpy", "qtawesome", - "spyder>=5.4.0", + # Uncomment when Spyder 6 is available + # "spyder>=6", ], packages=find_packages(), entry_points={ From 2c79ffb7aa996b561ceb411bdf75920ec9c1dfda Mon Sep 17 00:00:00 2001 From: dalthviz Date: Wed, 15 Feb 2023 18:57:08 -0500 Subject: [PATCH 02/14] Testing --- spyder_env_manager/spyder/plugin.py | 2 +- .../spyder/widgets/main_widget.py | 29 ++++--- spyder_env_manager/tests/test_main_widget.py | 16 +++- spyder_env_manager/tests/test_plugin.py | 86 +++++++++++++++++++ 4 files changed, 118 insertions(+), 15 deletions(-) diff --git a/spyder_env_manager/spyder/plugin.py b/spyder_env_manager/spyder/plugin.py index 3ede232..430c58f 100644 --- a/spyder_env_manager/spyder/plugin.py +++ b/spyder_env_manager/spyder/plugin.py @@ -53,7 +53,7 @@ def get_name(): return _("Environments Manager") def get_description(self): - return _("Spyder 5+ plugin to manage Python virtual environments and packages") + return _("Spyder 6+ plugin to manage Python virtual environments and packages") def get_icon(self): return qta.icon("mdi.archive", color=ima.MAIN_FG_COLOR) diff --git a/spyder_env_manager/spyder/widgets/main_widget.py b/spyder_env_manager/spyder/widgets/main_widget.py index c61386a..6a3fb2b 100644 --- a/spyder_env_manager/spyder/widgets/main_widget.py +++ b/spyder_env_manager/spyder/widgets/main_widget.py @@ -112,8 +112,8 @@ class SpyderEnvManagerWidget(PluginMainWidget): ENABLE_SPINNER = True NO_ENVIRONMENTS_AVAILABLE = _("No environments available") - def __init__(self, name=None, plugin=None, parent=None): - super().__init__(name, plugin, parent) + def __init__(self, name, plugin, parent=None): + super().__init__(name, plugin, parent=parent) # General attributes self.actions_enabled = True @@ -122,9 +122,10 @@ def __init__(self, name=None, plugin=None, parent=None): self.manager_worker = None # Select environment widget + root_path = self.get_conf("environments_path", str(DEFAULT_BACKENDS_ROOT_PATH)) envs, _ = Manager.list_environments( backend=CondaLikeInterface.ID, - root_path=self.get_conf("environments_path", DEFAULT_BACKENDS_ROOT_PATH), + root_path=root_path, external_executable=self.get_conf( "conda_file_executable_path", conda_like_executable() ), @@ -148,7 +149,7 @@ def __init__(self, name=None, plugin=None, parent=None): self.select_environment.setCurrentText(selected_environment) # Usage widget - self.css_path = self.get_conf("css_path", CSS_PATH, "appearance") + self.css_path = self.get_conf("css_path", str(CSS_PATH), "appearance") self.infowidget = FrameWebView(self) if WEBENGINE: self.infowidget.web_widget.page().setBackgroundColor(QColor(MAIN_BG_COLOR)) @@ -299,10 +300,10 @@ def current_environment_changed(self, index=None): """ if index: - current_environment = self.select_environment.itemText(index) + current_environment_path = self.select_environment.itemData(index) else: - current_environment = self.select_environment.currentText() - environments_available = current_environment != "No environments available" + current_environment_path = self.select_environment.currentData() + environments_available = current_environment_path is not None if environments_available: self.start_spinner() self._run_action_for_env( @@ -316,8 +317,8 @@ def current_environment_changed(self, index=None): def update_actions(self): if self.actions_enabled: - current_environment = self.select_environment.currentText() - environments_available = current_environment != "No environments available" + current_environment_path = self.select_environment.currentData() + environments_available = current_environment_path is not None actions_ids = [ SpyderEnvManagerWidgetActions.InstallPackage, SpyderEnvManagerWidgetActions.DeleteEnvironment, @@ -711,7 +712,9 @@ def _run_action_for_package(self, package_info, dialog=None, action=None): """ root_path = Path(self.get_conf("environments_path")) - external_executable = self.get_conf("conda_file_executable_path") + external_executable = self.get_conf( + "conda_file_executable_path", conda_like_executable() + ) backend = "conda-like" package_name = package_info["name"] if action == EnvironmentPackagesActions.UpdatePackage: @@ -792,7 +795,9 @@ def _run_action_for_env(self, dialog=None, action=None): """ root_path = Path(self.get_conf("environments_path")) - external_executable = self.get_conf("conda_file_executable_path") + external_executable = self.get_conf( + "conda_file_executable_path", conda_like_executable() + ) backend = "conda-like" if dialog and action == SpyderEnvManagerWidgetActions.NewEnvironment: backend = dialog.combobox.currentText() @@ -957,7 +962,7 @@ def _message_new_environment(self): contents = [ {"conda-like"}, {}, - ["3.7.15", "3.8.15", "3.9.15", "3.10.8"], + ["3.7", "3.8", "3.9", "3.10"], ] self._message_box_editable( title, diff --git a/spyder_env_manager/tests/test_main_widget.py b/spyder_env_manager/tests/test_main_widget.py index 83ef9ce..2d3161f 100644 --- a/spyder_env_manager/tests/test_main_widget.py +++ b/spyder_env_manager/tests/test_main_widget.py @@ -12,9 +12,21 @@ from spyder_env_manager.spyder.widgets.main_widget import SpyderEnvManagerWidget -def test_env_manager(qtbot): +def test_env_manager(qtbot, tmp_path, monkeypatch): """Create plugin widget and show it.""" + backends_root_path = tmp_path / "backends" + backends_root_path.mkdir(parents=True) + + def get_conf(self, option, default=None, section=None): + if option == "environments_path": + return str(backends_root_path) + else: + return default + + monkeypatch.setattr(SpyderEnvManagerWidget, "get_conf", get_conf) SpyderEnvManagerWidget.CONF_SECTION = "spyder_env_manager" - widget = SpyderEnvManagerWidget(None) + + widget = SpyderEnvManagerWidget("spyder_env_manager", None) + qtbot.addWidget(widget) widget.setup() widget.show() diff --git a/spyder_env_manager/tests/test_plugin.py b/spyder_env_manager/tests/test_plugin.py index bf77e57..e3bc8f5 100644 --- a/spyder_env_manager/tests/test_plugin.py +++ b/spyder_env_manager/tests/test_plugin.py @@ -7,3 +7,89 @@ """ Spyder Env Manager plugin tests. """ +# Standard library imports +from unittest.mock import Mock, patch + +# Third-party imports +import pytest +from qtpy.QtCore import QTimer +from qtpy.QtWidgets import QMainWindow + +# Spyder imports +from spyder.api.plugins import Plugins +from spyder.config.manager import CONF + +# Local imports +from spyder_env_manager.spyder.plugin import SpyderEnvManager +from spyder_env_manager.spyder.widgets.main_widget import SpyderEnvManagerWidget +from spyder_env_manager.spyder.widgets.helper_widgets import CustomParametersDialog + +# Constants +OPERATION_TIMEOUT = 100000 + + +# ---- Fixtures +# ------------------------------------------------------------------------ +class MainMock(QMainWindow): + def __init__(self): + super().__init__() + self.switcher = Mock() + self.main = self + self.resize(640, 480) + + def get_plugin(self, plugin_name, error=True): + return Mock() + + +@pytest.fixture +def spyder_env_manager(tmp_path, qtbot, monkeypatch): + backends_root_path = tmp_path / "backends" + backends_root_path.mkdir(parents=True) + window = MainMock() + + def get_conf(self, option, default=None, section=None): + if option == "environments_path": + return str(backends_root_path) + else: + return default + + monkeypatch.setattr(SpyderEnvManagerWidget, "get_conf", get_conf) + + plugin = SpyderEnvManager(parent=window, configuration=CONF) + widget = plugin.get_widget() + window.setCentralWidget(widget) + qtbot.addWidget(window) + window.show() + + yield widget + + qtbot.waitUntil(lambda: widget.actions_enabled, timeout=OPERATION_TIMEOUT) + widget.close() + + +def test_spyder_env_manager(spyder_env_manager, qtbot): + """Setup plugin widget, show it and create an environment.""" + assert ( + spyder_env_manager.select_environment.currentText() + == "No environments available" + ) + assert ( + spyder_env_manager.stack_layout.currentWidget() == spyder_env_manager.infowidget + ) + + def handle_env_creation_dialog(): + dialog = spyder_env_manager.findChild(CustomParametersDialog) + dialog.lineedit_string.setText("test_env") + dialog.combobox_edit.setCurrentText("3.9") + dialog.accept() + + QTimer.singleShot(100, handle_env_creation_dialog) + spyder_env_manager._message_new_environment() + + qtbot.waitUntil( + lambda: spyder_env_manager.stack_layout.currentWidget() + == spyder_env_manager.packages_table, + timeout=OPERATION_TIMEOUT, + ) + assert spyder_env_manager.select_environment.currentText() == "test_env" + assert spyder_env_manager.packages_table.source_model.rowCount() == 2 From 44e69ed2b8f18e28880919e89a3ed83f8a855b88 Mon Sep 17 00:00:00 2001 From: dalthviz Date: Thu, 16 Feb 2023 13:26:01 -0500 Subject: [PATCH 03/14] Update envs-manager constraint. Update test --- requirements/conda.txt | 2 +- setup.py | 2 +- spyder_env_manager/tests/test_plugin.py | 29 +++++++++++++++++-------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/requirements/conda.txt b/requirements/conda.txt index 2ad92db..9d78ad1 100644 --- a/requirements/conda.txt +++ b/requirements/conda.txt @@ -1,4 +1,4 @@ -envs-manager>=0.1.2 +envs-manager>=0.1.3 qtawesome qtpy setuptools diff --git a/setup.py b/setup.py index 6d14142..a81bfac 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ url="https://github.com/spyder-ide/spyder-env-manager", python_requires=">= 3.7", install_requires=[ - "envs-manager>=0.1.1", + "envs-manager>=0.1.3", "qtpy", "qtawesome", # Uncomment when Spyder 6 is available diff --git a/spyder_env_manager/tests/test_plugin.py b/spyder_env_manager/tests/test_plugin.py index e3bc8f5..f78e558 100644 --- a/spyder_env_manager/tests/test_plugin.py +++ b/spyder_env_manager/tests/test_plugin.py @@ -8,7 +8,8 @@ Spyder Env Manager plugin tests. """ # Standard library imports -from unittest.mock import Mock, patch +import logging +from unittest.mock import Mock # Third-party imports import pytest @@ -16,16 +17,20 @@ from qtpy.QtWidgets import QMainWindow # Spyder imports -from spyder.api.plugins import Plugins from spyder.config.manager import CONF # Local imports from spyder_env_manager.spyder.plugin import SpyderEnvManager -from spyder_env_manager.spyder.widgets.main_widget import SpyderEnvManagerWidget -from spyder_env_manager.spyder.widgets.helper_widgets import CustomParametersDialog +from spyder_env_manager.spyder.widgets.main_widget import ( + SpyderEnvManagerWidget, +) +from spyder_env_manager.spyder.widgets.helper_widgets import ( + CustomParametersDialog, +) # Constants -OPERATION_TIMEOUT = 100000 +LONG_OPERATION_TIMEOUT = 100000 +OPERATION_TIMEOUT = 50000 # ---- Fixtures @@ -63,12 +68,15 @@ def get_conf(self, option, default=None, section=None): yield widget - qtbot.waitUntil(lambda: widget.actions_enabled, timeout=OPERATION_TIMEOUT) + qtbot.waitUntil(lambda: widget.actions_enabled, timeout=LONG_OPERATION_TIMEOUT) widget.close() -def test_spyder_env_manager(spyder_env_manager, qtbot): +# ---- Tests +# ------------------------------------------------------------------------ +def test_spyder_env_manager(spyder_env_manager, qtbot, caplog): """Setup plugin widget, show it and create an environment.""" + caplog.set_level(logging.DEBUG) assert ( spyder_env_manager.select_environment.currentText() == "No environments available" @@ -89,7 +97,10 @@ def handle_env_creation_dialog(): qtbot.waitUntil( lambda: spyder_env_manager.stack_layout.currentWidget() == spyder_env_manager.packages_table, - timeout=OPERATION_TIMEOUT, + timeout=LONG_OPERATION_TIMEOUT, ) assert spyder_env_manager.select_environment.currentText() == "test_env" - assert spyder_env_manager.packages_table.source_model.rowCount() == 2 + qtbot.waitUntil( + lambda: spyder_env_manager.packages_table.source_model.rowCount() == 2, + timeout=OPERATION_TIMEOUT, + ) From 021efa0f920cdceb82e780361dce78615c23ac94 Mon Sep 17 00:00:00 2001 From: dalthviz Date: Thu, 16 Feb 2023 13:44:54 -0500 Subject: [PATCH 04/14] Add confpage test --- spyder_env_manager/spyder/confpage.py | 4 +-- spyder_env_manager/tests/test_config.py | 36 +++++++++++++++++++++++++ spyder_env_manager/tests/test_plugin.py | 25 +++++++---------- 3 files changed, 48 insertions(+), 17 deletions(-) create mode 100644 spyder_env_manager/tests/test_config.py diff --git a/spyder_env_manager/spyder/confpage.py b/spyder_env_manager/spyder/confpage.py index d1af190..ece91c8 100644 --- a/spyder_env_manager/spyder/confpage.py +++ b/spyder_env_manager/spyder/confpage.py @@ -29,7 +29,7 @@ def setup_page(self): conda_like_path_label.setToolTip(_("Path to the conda/micromamba executable")) conda_like_path_label.setWordWrap(True) - conda_like_path = QLabel(self.get_option("conda_file_executable_path")) + conda_like_path = QLabel(self.get_option("conda_file_executable_path", None)) conda_like_path.setTextInteractionFlags(Qt.TextSelectableByMouse) conda_like_path.setWordWrap(True) @@ -42,7 +42,7 @@ def setup_page(self): ) environments_path_label.setWordWrap(True) - environments_path = QLabel(self.get_option("environments_path")) + environments_path = QLabel(self.get_option("environments_path", None)) environments_path.setTextInteractionFlags(Qt.TextSelectableByMouse) environments_path.setWordWrap(True) diff --git a/spyder_env_manager/tests/test_config.py b/spyder_env_manager/tests/test_config.py new file mode 100644 index 0000000..e064ed5 --- /dev/null +++ b/spyder_env_manager/tests/test_config.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +# ---------------------------------------------------------------------------- +# Copyright © 2022, Spyder Development Team and spyder-env-manager contributors +# +# Licensed under the terms of the MIT license +# ---------------------------------------------------------------------------- +""" +Spyder Env Manager ConfigPage tests. +""" + +# Third-party library imports +import pytest + +# Spyder imports +from spyder.plugins.preferences.widgets.configdialog import ConfigDialog + +# Local imports +from spyder_env_manager.spyder.confpage import SpyderEnvManagerConfigPage +from spyder_env_manager.tests.test_plugin import spyder_env_manager + + +def test_config(spyder_env_manager, qtbot): + """Test that config page can be created and shown.""" + dlg = ConfigDialog() + page = SpyderEnvManagerConfigPage( + spyder_env_manager, parent=spyder_env_manager.main + ) + page.initialize() + dlg.add_page(page) + dlg.show() + qtbot.addWidget(dlg) + # no assert, just check that the config page can be created + + +if __name__ == "__main__": + pytest.main() diff --git a/spyder_env_manager/tests/test_plugin.py b/spyder_env_manager/tests/test_plugin.py index f78e558..fa95a53 100644 --- a/spyder_env_manager/tests/test_plugin.py +++ b/spyder_env_manager/tests/test_plugin.py @@ -66,7 +66,7 @@ def get_conf(self, option, default=None, section=None): qtbot.addWidget(window) window.show() - yield widget + yield plugin qtbot.waitUntil(lambda: widget.actions_enabled, timeout=LONG_OPERATION_TIMEOUT) widget.close() @@ -77,30 +77,25 @@ def get_conf(self, option, default=None, section=None): def test_spyder_env_manager(spyder_env_manager, qtbot, caplog): """Setup plugin widget, show it and create an environment.""" caplog.set_level(logging.DEBUG) - assert ( - spyder_env_manager.select_environment.currentText() - == "No environments available" - ) - assert ( - spyder_env_manager.stack_layout.currentWidget() == spyder_env_manager.infowidget - ) + widget = spyder_env_manager.get_widget() + assert widget.select_environment.currentText() == "No environments available" + assert widget.stack_layout.currentWidget() == widget.infowidget def handle_env_creation_dialog(): - dialog = spyder_env_manager.findChild(CustomParametersDialog) + dialog = widget.findChild(CustomParametersDialog) dialog.lineedit_string.setText("test_env") - dialog.combobox_edit.setCurrentText("3.9") + dialog.combobox_edit.setCurrentText("3.8") dialog.accept() QTimer.singleShot(100, handle_env_creation_dialog) - spyder_env_manager._message_new_environment() + widget._message_new_environment() qtbot.waitUntil( - lambda: spyder_env_manager.stack_layout.currentWidget() - == spyder_env_manager.packages_table, + lambda: widget.stack_layout.currentWidget() == widget.packages_table, timeout=LONG_OPERATION_TIMEOUT, ) - assert spyder_env_manager.select_environment.currentText() == "test_env" + assert widget.select_environment.currentText() == "test_env" qtbot.waitUntil( - lambda: spyder_env_manager.packages_table.source_model.rowCount() == 2, + lambda: widget.packages_table.source_model.rowCount() == 2, timeout=OPERATION_TIMEOUT, ) From 891a1f7e2025e7f4434d7f03a869093da6602557 Mon Sep 17 00:00:00 2001 From: dalthviz Date: Thu, 16 Feb 2023 14:52:29 -0500 Subject: [PATCH 05/14] More tests. Add constraint for spyder 6 on setup.py --- setup.py | 4 +-- spyder_env_manager/tests/test_config.py | 2 +- spyder_env_manager/tests/test_main_widget.py | 4 +-- spyder_env_manager/tests/test_plugin.py | 36 +++++++++++++++++--- 4 files changed, 36 insertions(+), 10 deletions(-) diff --git a/setup.py b/setup.py index a81bfac..bf24663 100644 --- a/setup.py +++ b/setup.py @@ -25,8 +25,7 @@ "envs-manager>=0.1.3", "qtpy", "qtawesome", - # Uncomment when Spyder 6 is available - # "spyder>=6", + "spyder>=6", ], packages=find_packages(), entry_points={ @@ -42,6 +41,7 @@ "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Education", "Intended Audience :: Science/Research", diff --git a/spyder_env_manager/tests/test_config.py b/spyder_env_manager/tests/test_config.py index e064ed5..7a0f877 100644 --- a/spyder_env_manager/tests/test_config.py +++ b/spyder_env_manager/tests/test_config.py @@ -27,8 +27,8 @@ def test_config(spyder_env_manager, qtbot): ) page.initialize() dlg.add_page(page) - dlg.show() qtbot.addWidget(dlg) + dlg.show() # no assert, just check that the config page can be created diff --git a/spyder_env_manager/tests/test_main_widget.py b/spyder_env_manager/tests/test_main_widget.py index 2d3161f..22112b5 100644 --- a/spyder_env_manager/tests/test_main_widget.py +++ b/spyder_env_manager/tests/test_main_widget.py @@ -12,8 +12,8 @@ from spyder_env_manager.spyder.widgets.main_widget import SpyderEnvManagerWidget -def test_env_manager(qtbot, tmp_path, monkeypatch): - """Create plugin widget and show it.""" +def test_main_widget(qtbot, tmp_path, monkeypatch): + """Create widget and show it.""" backends_root_path = tmp_path / "backends" backends_root_path.mkdir(parents=True) diff --git a/spyder_env_manager/tests/test_plugin.py b/spyder_env_manager/tests/test_plugin.py index fa95a53..1f38c8f 100644 --- a/spyder_env_manager/tests/test_plugin.py +++ b/spyder_env_manager/tests/test_plugin.py @@ -23,6 +23,7 @@ from spyder_env_manager.spyder.plugin import SpyderEnvManager from spyder_env_manager.spyder.widgets.main_widget import ( SpyderEnvManagerWidget, + SpyderEnvManagerWidgetActions, ) from spyder_env_manager.spyder.widgets.helper_widgets import ( CustomParametersDialog, @@ -48,9 +49,10 @@ def get_plugin(self, plugin_name, error=True): @pytest.fixture def spyder_env_manager(tmp_path, qtbot, monkeypatch): + # Mocking mainwindow and config + window = MainMock() backends_root_path = tmp_path / "backends" backends_root_path.mkdir(parents=True) - window = MainMock() def get_conf(self, option, default=None, section=None): if option == "environments_path": @@ -60,6 +62,7 @@ def get_conf(self, option, default=None, section=None): monkeypatch.setattr(SpyderEnvManagerWidget, "get_conf", get_conf) + # Setup plugin plugin = SpyderEnvManager(parent=window, configuration=CONF) widget = plugin.get_widget() window.setCentralWidget(widget) @@ -68,19 +71,42 @@ def get_conf(self, option, default=None, section=None): yield plugin + # Wait for pending operations and close qtbot.waitUntil(lambda: widget.actions_enabled, timeout=LONG_OPERATION_TIMEOUT) widget.close() + del plugin + del window # ---- Tests # ------------------------------------------------------------------------ -def test_spyder_env_manager(spyder_env_manager, qtbot, caplog): - """Setup plugin widget, show it and create an environment.""" - caplog.set_level(logging.DEBUG) +def test_plugin_initial_state(spyder_env_manager, qtbot): + """Check plugin initialization and that actions and widgets have the correct state when initializing.""" widget = spyder_env_manager.get_widget() - assert widget.select_environment.currentText() == "No environments available" + + # Check for widgets initialization + assert widget.select_environment.currentData() is None + assert widget.select_environment.isEnabled() assert widget.stack_layout.currentWidget() == widget.infowidget + # Check widget actions + disabled_actions_ids = [ + SpyderEnvManagerWidgetActions.InstallPackage, + SpyderEnvManagerWidgetActions.DeleteEnvironment, + SpyderEnvManagerWidgetActions.ExportEnvironment, + ] + for action_id, action in widget.get_actions().items(): + if action_id in disabled_actions_ids: + assert not action.isEnabled() + else: + assert action.isEnabled() + + +def test_environment_creation(spyder_env_manager, qtbot, caplog): + """Test creating an environment.""" + caplog.set_level(logging.DEBUG) + widget = spyder_env_manager.get_widget() + def handle_env_creation_dialog(): dialog = widget.findChild(CustomParametersDialog) dialog.lineedit_string.setText("test_env") From f4d691fa5185d453ae7dde22f6ef57a15dd121d2 Mon Sep 17 00:00:00 2001 From: dalthviz Date: Thu, 16 Feb 2023 16:59:02 -0500 Subject: [PATCH 06/14] Import test --- spyder_env_manager/tests/data/import_env.yml | 6 ++++ spyder_env_manager/tests/test_plugin.py | 31 ++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 spyder_env_manager/tests/data/import_env.yml diff --git a/spyder_env_manager/tests/data/import_env.yml b/spyder_env_manager/tests/data/import_env.yml new file mode 100644 index 0000000..d56abe7 --- /dev/null +++ b/spyder_env_manager/tests/data/import_env.yml @@ -0,0 +1,6 @@ +name: +channels: +- https://conda.anaconda.org/conda-forge +dependencies: +- packaging=21.3 +- python=3.10.5 diff --git a/spyder_env_manager/tests/test_plugin.py b/spyder_env_manager/tests/test_plugin.py index 1f38c8f..e696c58 100644 --- a/spyder_env_manager/tests/test_plugin.py +++ b/spyder_env_manager/tests/test_plugin.py @@ -9,6 +9,7 @@ """ # Standard library imports import logging +from pathlib import Path from unittest.mock import Mock # Third-party imports @@ -32,6 +33,7 @@ # Constants LONG_OPERATION_TIMEOUT = 100000 OPERATION_TIMEOUT = 50000 +IMPORT_FILE_PATH = str(Path(__file__).parent / "data" / "import_env.yml") # ---- Fixtures @@ -107,13 +109,13 @@ def test_environment_creation(spyder_env_manager, qtbot, caplog): caplog.set_level(logging.DEBUG) widget = spyder_env_manager.get_widget() - def handle_env_creation_dialog(): + def handle_environment_creation_dialog(): dialog = widget.findChild(CustomParametersDialog) dialog.lineedit_string.setText("test_env") dialog.combobox_edit.setCurrentText("3.8") dialog.accept() - QTimer.singleShot(100, handle_env_creation_dialog) + QTimer.singleShot(100, handle_environment_creation_dialog) widget._message_new_environment() qtbot.waitUntil( @@ -125,3 +127,28 @@ def handle_env_creation_dialog(): lambda: widget.packages_table.source_model.rowCount() == 2, timeout=OPERATION_TIMEOUT, ) + + +def test_environment_import(spyder_env_manager, qtbot, caplog): + """Test importing an environment from a file.""" + caplog.set_level(logging.DEBUG) + widget = spyder_env_manager.get_widget() + + def handle_environment_import_dialog(): + dialog = widget.findChild(CustomParametersDialog) + dialog.lineedit_string.setText("test_env_import") + dialog.file_combobox.combobox.lineEdit().setText(IMPORT_FILE_PATH) + dialog.accept() + + QTimer.singleShot(100, handle_environment_import_dialog) + widget._message_import_environment() + + qtbot.waitUntil( + lambda: widget.stack_layout.currentWidget() == widget.packages_table, + timeout=LONG_OPERATION_TIMEOUT, + ) + assert widget.select_environment.currentText() == "test_env_import" + qtbot.waitUntil( + lambda: widget.packages_table.source_model.rowCount() == 3, + timeout=OPERATION_TIMEOUT, + ) From 46aad9f9e59d18ceb0a6219251e0696ccdce4c86 Mon Sep 17 00:00:00 2001 From: dalthviz Date: Mon, 20 Feb 2023 13:38:07 -0500 Subject: [PATCH 07/14] Install test --- .github/workflows/linux-tests.yml | 1 + .../spyder/widgets/helper_widgets.py | 2 +- .../spyder/widgets/main_widget.py | 4 +- spyder_env_manager/tests/test_config.py | 6 +- spyder_env_manager/tests/test_plugin.py | 111 ++++++++++++++++-- 5 files changed, 106 insertions(+), 18 deletions(-) diff --git a/.github/workflows/linux-tests.yml b/.github/workflows/linux-tests.yml index e7dc968..0857dbf 100644 --- a/.github/workflows/linux-tests.yml +++ b/.github/workflows/linux-tests.yml @@ -21,6 +21,7 @@ jobs: matrix: PYTHON_VERSION: ['3.8', '3.9', '3.10'] USE_CONDA: ['True', 'False'] + timeout-minutes: 15 steps: - name: Checkout branch uses: actions/checkout@v2 diff --git a/spyder_env_manager/spyder/widgets/helper_widgets.py b/spyder_env_manager/spyder/widgets/helper_widgets.py index 35971d8..599a157 100644 --- a/spyder_env_manager/spyder/widgets/helper_widgets.py +++ b/spyder_env_manager/spyder/widgets/helper_widgets.py @@ -58,7 +58,7 @@ def __init__(self, parent, title, messages, types, contents): super().__init__(parent, Qt.WindowTitleHint | Qt.WindowCloseButtonHint) self.resize(450, 130) - self.setWindowTitle(_(title)) + self.setWindowTitle(title) self.setModal(True) self.lineedits = {} diff --git a/spyder_env_manager/spyder/widgets/main_widget.py b/spyder_env_manager/spyder/widgets/main_widget.py index 6a3fb2b..90deeb7 100644 --- a/spyder_env_manager/spyder/widgets/main_widget.py +++ b/spyder_env_manager/spyder/widgets/main_widget.py @@ -681,9 +681,9 @@ def _run_env_manager_action( *manager_action_args, **manager_action_kwargs, ) + self.manager_worker.moveToThread(self.env_manager_action_thread) self.manager_worker.sig_ready.connect(on_ready) self.manager_worker.sig_ready.connect(self.env_manager_action_thread.quit) - self.manager_worker.moveToThread(self.env_manager_action_thread) self.env_manager_action_thread.started.connect(self.manager_worker.start) self.start_spinner() self.env_manager_action_thread.start() @@ -962,7 +962,7 @@ def _message_new_environment(self): contents = [ {"conda-like"}, {}, - ["3.7", "3.8", "3.9", "3.10"], + ["3.7.12", "3.8.16", "3.9.16", "3.10.9"], ] self._message_box_editable( title, diff --git a/spyder_env_manager/tests/test_config.py b/spyder_env_manager/tests/test_config.py index 7a0f877..f31df99 100644 --- a/spyder_env_manager/tests/test_config.py +++ b/spyder_env_manager/tests/test_config.py @@ -16,14 +16,14 @@ # Local imports from spyder_env_manager.spyder.confpage import SpyderEnvManagerConfigPage -from spyder_env_manager.tests.test_plugin import spyder_env_manager +from spyder_env_manager.tests.test_plugin import spyder_env_manager_conf -def test_config(spyder_env_manager, qtbot): +def test_config(spyder_env_manager_conf, qtbot): """Test that config page can be created and shown.""" dlg = ConfigDialog() page = SpyderEnvManagerConfigPage( - spyder_env_manager, parent=spyder_env_manager.main + spyder_env_manager_conf, parent=spyder_env_manager_conf.main ) page.initialize() dlg.add_page(page) diff --git a/spyder_env_manager/tests/test_plugin.py b/spyder_env_manager/tests/test_plugin.py index e696c58..d8ea083 100644 --- a/spyder_env_manager/tests/test_plugin.py +++ b/spyder_env_manager/tests/test_plugin.py @@ -31,7 +31,7 @@ ) # Constants -LONG_OPERATION_TIMEOUT = 100000 +LONG_OPERATION_TIMEOUT = 600000 OPERATION_TIMEOUT = 50000 IMPORT_FILE_PATH = str(Path(__file__).parent / "data" / "import_env.yml") @@ -49,6 +49,36 @@ def get_plugin(self, plugin_name, error=True): return Mock() +@pytest.fixture +def spyder_env_manager_conf(tmp_path, qtbot, monkeypatch): + # Mocking mainwindow and get_config + window = MainMock() + backends_root_path = tmp_path / "backends" + backends_root_path.mkdir(parents=True) + + def get_conf(self, option, default=None, section=None): + if option == "environments_path": + return str(backends_root_path) + else: + return default + + monkeypatch.setattr(SpyderEnvManagerWidget, "get_conf", get_conf) + + # Setup plugin + plugin = SpyderEnvManager(parent=window, configuration=CONF) + window.setCentralWidget(plugin.get_widget()) + window.show() + + yield plugin + + # Wait for pending operations and close + qtbot.waitUntil( + lambda: plugin.get_widget().actions_enabled, + timeout=LONG_OPERATION_TIMEOUT, + ) + plugin.get_widget().close() + + @pytest.fixture def spyder_env_manager(tmp_path, qtbot, monkeypatch): # Mocking mainwindow and config @@ -65,24 +95,23 @@ def get_conf(self, option, default=None, section=None): monkeypatch.setattr(SpyderEnvManagerWidget, "get_conf", get_conf) # Setup plugin - plugin = SpyderEnvManager(parent=window, configuration=CONF) - widget = plugin.get_widget() - window.setCentralWidget(widget) - qtbot.addWidget(window) + plugin = SpyderEnvManager(parent=window, configuration=Mock()) + window.setCentralWidget(plugin.get_widget()) window.show() yield plugin # Wait for pending operations and close - qtbot.waitUntil(lambda: widget.actions_enabled, timeout=LONG_OPERATION_TIMEOUT) - widget.close() - del plugin - del window + qtbot.waitUntil( + lambda: plugin.get_widget().actions_enabled, + timeout=LONG_OPERATION_TIMEOUT, + ) + plugin.get_widget().close() # ---- Tests # ------------------------------------------------------------------------ -def test_plugin_initial_state(spyder_env_manager, qtbot): +def test_plugin_initial_state(spyder_env_manager): """Check plugin initialization and that actions and widgets have the correct state when initializing.""" widget = spyder_env_manager.get_widget() @@ -105,14 +134,15 @@ def test_plugin_initial_state(spyder_env_manager, qtbot): def test_environment_creation(spyder_env_manager, qtbot, caplog): - """Test creating an environment.""" + """Test creating an environment and installing a package in it.""" caplog.set_level(logging.DEBUG) widget = spyder_env_manager.get_widget() + # Create environment def handle_environment_creation_dialog(): dialog = widget.findChild(CustomParametersDialog) dialog.lineedit_string.setText("test_env") - dialog.combobox_edit.setCurrentText("3.8") + dialog.combobox_edit.setCurrentText("3.8.16") dialog.accept() QTimer.singleShot(100, handle_environment_creation_dialog) @@ -152,3 +182,60 @@ def handle_environment_import_dialog(): lambda: widget.packages_table.source_model.rowCount() == 3, timeout=OPERATION_TIMEOUT, ) + + +def test_environment_package_installation(spyder_env_manager, qtbot, caplog): + """Test creating an environment and installing a package in it.""" + caplog.set_level(logging.DEBUG) + widget = spyder_env_manager.get_widget() + + # Create environment + create_dialog = Mock() + create_dialog.combobox = combobox_mock = Mock() + combobox_mock.currentText = Mock(return_value="conda-like") + create_dialog.lineedit_string = lineedit_string_mock = Mock() + lineedit_string_mock.text = Mock(return_value="test_env") + create_dialog.combobox_edit = combobox_edit_mock = Mock() + combobox_edit_mock.currentText = Mock(return_value="3.9.16") + + assert create_dialog.combobox.currentText() == "conda-like" + assert create_dialog.lineedit_string.text() == "test_env" + assert create_dialog.combobox_edit.currentText() == "3.9.16" + + widget._run_action_for_env( + dialog=create_dialog, action=SpyderEnvManagerWidgetActions.NewEnvironment + ) + + qtbot.waitUntil( + lambda: widget.stack_layout.currentWidget() == widget.packages_table, + timeout=LONG_OPERATION_TIMEOUT, + ) + assert widget.select_environment.currentText() == "test_env" + qtbot.waitUntil( + lambda: widget.packages_table.source_model.rowCount() == 2, + timeout=OPERATION_TIMEOUT, + ) + + # Install package in environment + install_dialog = Mock() + install_dialog.lineedit_string = lineedit_string_mock = Mock() + lineedit_string_mock.text = Mock(return_value="packaging") + install_dialog.combobox = combobox_mock = Mock() + combobox_mock.currentText = Mock(return_value="==") + install_dialog.lineedit_version = lineedit_version_mock = Mock() + lineedit_version_mock.text = Mock(return_value="22.0") + + assert install_dialog.lineedit_string.text() == "packaging" + assert install_dialog.combobox.currentText() == "==" + assert install_dialog.lineedit_version.text() == "22.0" + + widget._run_action_for_env( + dialog=install_dialog, action=SpyderEnvManagerWidgetActions.InstallPackage + ) + + qtbot.waitUntil( + lambda: widget.packages_table.source_model.rowCount() == 3, + timeout=LONG_OPERATION_TIMEOUT, + ) + assert widget.packages_table.get_package_info(0)["name"] == "packaging" + assert widget.packages_table.get_package_info(0)["version"] == "22.0" From ba3f34bae9d88f510cfd94e2b984192c8aebc7f9 Mon Sep 17 00:00:00 2001 From: dalthviz Date: Mon, 20 Feb 2023 14:23:32 -0500 Subject: [PATCH 08/14] Delete test --- spyder_env_manager/tests/test_plugin.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/spyder_env_manager/tests/test_plugin.py b/spyder_env_manager/tests/test_plugin.py index d8ea083..d53f59e 100644 --- a/spyder_env_manager/tests/test_plugin.py +++ b/spyder_env_manager/tests/test_plugin.py @@ -133,8 +133,8 @@ def test_plugin_initial_state(spyder_env_manager): assert action.isEnabled() -def test_environment_creation(spyder_env_manager, qtbot, caplog): - """Test creating an environment and installing a package in it.""" +def test_environment_creation_and_deletion(spyder_env_manager, qtbot, caplog): + """Test creating and deleting an environment.""" caplog.set_level(logging.DEBUG) widget = spyder_env_manager.get_widget() @@ -158,6 +158,17 @@ def handle_environment_creation_dialog(): timeout=OPERATION_TIMEOUT, ) + # Delete environment + widget._run_action_for_env( + dialog=None, action=SpyderEnvManagerWidgetActions.DeleteEnvironment + ) + + qtbot.waitUntil( + lambda: widget.stack_layout.currentWidget() == widget.infowidget, + timeout=LONG_OPERATION_TIMEOUT, + ) + assert widget.select_environment.currentData() is None + def test_environment_import(spyder_env_manager, qtbot, caplog): """Test importing an environment from a file.""" From aae97e6b4e59b04468a14e64391fd3f9aef74b45 Mon Sep 17 00:00:00 2001 From: dalthviz Date: Thu, 23 Feb 2023 18:21:03 -0500 Subject: [PATCH 09/14] Update tests fixtures and usage of get_conf default arg --- .../spyder/widgets/main_widget.py | 20 ++++++------------- spyder_env_manager/tests/test_main_widget.py | 2 +- spyder_env_manager/tests/test_plugin.py | 20 +++++++++++++++---- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/spyder_env_manager/spyder/widgets/main_widget.py b/spyder_env_manager/spyder/widgets/main_widget.py index 4384549..5c06f00 100644 --- a/spyder_env_manager/spyder/widgets/main_widget.py +++ b/spyder_env_manager/spyder/widgets/main_widget.py @@ -137,13 +137,11 @@ def __init__(self, name, plugin, parent=None): self.manager_worker = None # Select environment widget - root_path = self.get_conf("environments_path", str(DEFAULT_BACKENDS_ROOT_PATH)) + root_path = self.get_conf("environments_path") envs, _ = Manager.list_environments( backend=CondaLikeInterface.ID, root_path=root_path, - external_executable=self.get_conf( - "conda_file_executable_path", conda_like_executable() - ), + external_executable=self.get_conf("conda_file_executable_path"), ) self.select_environment = QComboBox(self) self.select_environment.ID = SpyderEnvManagerWidgetActions.SelectEnvironment @@ -159,7 +157,7 @@ def __init__(self, name, plugin, parent=None): QComboBox.AdjustToMinimumContentsLength ) self.select_environment.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) - selected_environment = self.get_conf("selected_environment", None) + selected_environment = self.get_conf("selected_environment") if selected_environment: self.select_environment.setCurrentText(selected_environment) @@ -521,9 +519,7 @@ def _environment_as_custom_interpreter(self, environment_path=None): environment_path = self.select_environment.currentData() if not environment_path: return - external_executable = self.get_conf( - "conda_file_executable_path", conda_like_executable() - ) + external_executable = self.get_conf("conda_file_executable_path") backend = "conda-like" manager = Manager( backend, @@ -793,9 +789,7 @@ def _run_action_for_package(self, package_info, dialog=None, action=None): """ root_path = Path(self.get_conf("environments_path")) - external_executable = self.get_conf( - "conda_file_executable_path", conda_like_executable() - ) + external_executable = self.get_conf("conda_file_executable_path") backend = "conda-like" package_name = package_info["name"] if action == EnvironmentPackagesActions.UpdatePackage: @@ -876,9 +870,7 @@ def _run_action_for_env(self, dialog=None, action=None): """ root_path = Path(self.get_conf("environments_path")) - external_executable = self.get_conf( - "conda_file_executable_path", conda_like_executable() - ) + external_executable = self.get_conf("conda_file_executable_path") backend = "conda-like" if dialog and action == SpyderEnvManagerWidgetActions.NewEnvironment: backend = dialog.combobox.currentText() diff --git a/spyder_env_manager/tests/test_main_widget.py b/spyder_env_manager/tests/test_main_widget.py index 6a91dd7..905759f 100644 --- a/spyder_env_manager/tests/test_main_widget.py +++ b/spyder_env_manager/tests/test_main_widget.py @@ -30,6 +30,6 @@ def get_conf(self, option, default=None, section=None): monkeypatch.setattr(SpyderEnvManagerWidget, "get_conf", get_conf) SpyderEnvManagerWidget.CONF_SECTION = CONF_SECTION - widget = SpyderEnvManagerWidget(None) + widget = SpyderEnvManagerWidget(None, None) widget.setup() widget.show() diff --git a/spyder_env_manager/tests/test_plugin.py b/spyder_env_manager/tests/test_plugin.py index d53f59e..29f4814 100644 --- a/spyder_env_manager/tests/test_plugin.py +++ b/spyder_env_manager/tests/test_plugin.py @@ -21,6 +21,7 @@ from spyder.config.manager import CONF # Local imports +from spyder_env_manager.spyder.config import CONF_DEFAULTS from spyder_env_manager.spyder.plugin import SpyderEnvManager from spyder_env_manager.spyder.widgets.main_widget import ( SpyderEnvManagerWidget, @@ -60,7 +61,11 @@ def get_conf(self, option, default=None, section=None): if option == "environments_path": return str(backends_root_path) else: - return default + try: + _, config_default_values = CONF_DEFAULTS[0] + return config_default_values[option] + except KeyError: + return None monkeypatch.setattr(SpyderEnvManagerWidget, "get_conf", get_conf) @@ -81,7 +86,7 @@ def get_conf(self, option, default=None, section=None): @pytest.fixture def spyder_env_manager(tmp_path, qtbot, monkeypatch): - # Mocking mainwindow and config + # Mocking mainwindow, get_config and CONF window = MainMock() backends_root_path = tmp_path / "backends" backends_root_path.mkdir(parents=True) @@ -90,7 +95,11 @@ def get_conf(self, option, default=None, section=None): if option == "environments_path": return str(backends_root_path) else: - return default + try: + _, config_default_values = CONF_DEFAULTS[0] + return config_default_values[option] + except KeyError: + return None monkeypatch.setattr(SpyderEnvManagerWidget, "get_conf", get_conf) @@ -112,7 +121,10 @@ def get_conf(self, option, default=None, section=None): # ---- Tests # ------------------------------------------------------------------------ def test_plugin_initial_state(spyder_env_manager): - """Check plugin initialization and that actions and widgets have the correct state when initializing.""" + """ + Check plugin initialization and that actions and widgets have the + correct state when initializing. + """ widget = spyder_env_manager.get_widget() # Check for widgets initialization From 8b7ac82c2447ead0923e96b4c0c0c368fd32e233 Mon Sep 17 00:00:00 2001 From: dalthviz Date: Fri, 24 Feb 2023 13:51:27 -0500 Subject: [PATCH 10/14] Update test and fixtures --- spyder_env_manager/tests/test_plugin.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spyder_env_manager/tests/test_plugin.py b/spyder_env_manager/tests/test_plugin.py index 29f4814..330bb7d 100644 --- a/spyder_env_manager/tests/test_plugin.py +++ b/spyder_env_manager/tests/test_plugin.py @@ -82,6 +82,7 @@ def get_conf(self, option, default=None, section=None): timeout=LONG_OPERATION_TIMEOUT, ) plugin.get_widget().close() + window.close() @pytest.fixture @@ -116,6 +117,7 @@ def get_conf(self, option, default=None, section=None): timeout=LONG_OPERATION_TIMEOUT, ) plugin.get_widget().close() + window.close() # ---- Tests @@ -137,6 +139,8 @@ def test_plugin_initial_state(spyder_env_manager): SpyderEnvManagerWidgetActions.InstallPackage, SpyderEnvManagerWidgetActions.DeleteEnvironment, SpyderEnvManagerWidgetActions.ExportEnvironment, + SpyderEnvManagerWidgetActions.ToggleExcludeDependency, + SpyderEnvManagerWidgetActions.ToggleEnvironmentAsCustomInterpreter, ] for action_id, action in widget.get_actions().items(): if action_id in disabled_actions_ids: From 7bab2ddc1d30e26fc2f7f74925c9d1564fa54444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Althviz=20Mor=C3=A9?= Date: Tue, 28 Feb 2023 13:01:40 -0500 Subject: [PATCH 11/14] Apply suggestions from code review Co-authored-by: Carlos Cordoba --- spyder_env_manager/tests/test_plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spyder_env_manager/tests/test_plugin.py b/spyder_env_manager/tests/test_plugin.py index 330bb7d..f2c3c88 100644 --- a/spyder_env_manager/tests/test_plugin.py +++ b/spyder_env_manager/tests/test_plugin.py @@ -125,7 +125,7 @@ def get_conf(self, option, default=None, section=None): def test_plugin_initial_state(spyder_env_manager): """ Check plugin initialization and that actions and widgets have the - correct state when initializing. + correct state when initialized. """ widget = spyder_env_manager.get_widget() @@ -212,7 +212,7 @@ def handle_environment_import_dialog(): def test_environment_package_installation(spyder_env_manager, qtbot, caplog): - """Test creating an environment and installing a package in it.""" + """Test creating an environment and installing a package on it.""" caplog.set_level(logging.DEBUG) widget = spyder_env_manager.get_widget() From f94671ebbe21859c0edc7983e962df99731a8967 Mon Sep 17 00:00:00 2001 From: dalthviz Date: Tue, 28 Feb 2023 13:20:54 -0500 Subject: [PATCH 12/14] Remove Python 3.7 and add Python 3.11 --- setup.py | 4 ++-- spyder_env_manager/spyder/widgets/main_widget.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index bf24663..9997509 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ description="Spyder 6+ plugin to manage Python virtual environments and packages", license="MIT license", url="https://github.com/spyder-ide/spyder-env-manager", - python_requires=">= 3.7", + python_requires=">= 3.8", install_requires=[ "envs-manager>=0.1.3", "qtpy", @@ -38,10 +38,10 @@ "Operating System :: Microsoft :: Windows", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Education", "Intended Audience :: Science/Research", diff --git a/spyder_env_manager/spyder/widgets/main_widget.py b/spyder_env_manager/spyder/widgets/main_widget.py index 5c06f00..95ac269 100644 --- a/spyder_env_manager/spyder/widgets/main_widget.py +++ b/spyder_env_manager/spyder/widgets/main_widget.py @@ -1035,7 +1035,7 @@ def _message_new_environment(self): contents = [ {"conda-like"}, {}, - ["3.7.12", "3.8.16", "3.9.16", "3.10.9"], + ["3.8.16", "3.9.16", "3.10.9", "3.11.0"], ] self._message_box_editable( title, From 88bb224322765d328fea2544bd6c23fde03928a1 Mon Sep 17 00:00:00 2001 From: dalthviz Date: Tue, 28 Feb 2023 14:11:30 -0500 Subject: [PATCH 13/14] Remove LONG_OPERATION_TIMEOUT and use OPERATION_TIMEOUT (1 min) for tests --- spyder_env_manager/tests/test_plugin.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/spyder_env_manager/tests/test_plugin.py b/spyder_env_manager/tests/test_plugin.py index f2c3c88..45f047e 100644 --- a/spyder_env_manager/tests/test_plugin.py +++ b/spyder_env_manager/tests/test_plugin.py @@ -32,8 +32,7 @@ ) # Constants -LONG_OPERATION_TIMEOUT = 600000 -OPERATION_TIMEOUT = 50000 +OPERATION_TIMEOUT = 60000 IMPORT_FILE_PATH = str(Path(__file__).parent / "data" / "import_env.yml") @@ -79,7 +78,7 @@ def get_conf(self, option, default=None, section=None): # Wait for pending operations and close qtbot.waitUntil( lambda: plugin.get_widget().actions_enabled, - timeout=LONG_OPERATION_TIMEOUT, + timeout=OPERATION_TIMEOUT, ) plugin.get_widget().close() window.close() @@ -114,7 +113,7 @@ def get_conf(self, option, default=None, section=None): # Wait for pending operations and close qtbot.waitUntil( lambda: plugin.get_widget().actions_enabled, - timeout=LONG_OPERATION_TIMEOUT, + timeout=OPERATION_TIMEOUT, ) plugin.get_widget().close() window.close() @@ -166,7 +165,7 @@ def handle_environment_creation_dialog(): qtbot.waitUntil( lambda: widget.stack_layout.currentWidget() == widget.packages_table, - timeout=LONG_OPERATION_TIMEOUT, + timeout=OPERATION_TIMEOUT, ) assert widget.select_environment.currentText() == "test_env" qtbot.waitUntil( @@ -181,7 +180,7 @@ def handle_environment_creation_dialog(): qtbot.waitUntil( lambda: widget.stack_layout.currentWidget() == widget.infowidget, - timeout=LONG_OPERATION_TIMEOUT, + timeout=OPERATION_TIMEOUT, ) assert widget.select_environment.currentData() is None @@ -202,7 +201,7 @@ def handle_environment_import_dialog(): qtbot.waitUntil( lambda: widget.stack_layout.currentWidget() == widget.packages_table, - timeout=LONG_OPERATION_TIMEOUT, + timeout=OPERATION_TIMEOUT, ) assert widget.select_environment.currentText() == "test_env_import" qtbot.waitUntil( @@ -235,7 +234,7 @@ def test_environment_package_installation(spyder_env_manager, qtbot, caplog): qtbot.waitUntil( lambda: widget.stack_layout.currentWidget() == widget.packages_table, - timeout=LONG_OPERATION_TIMEOUT, + timeout=OPERATION_TIMEOUT, ) assert widget.select_environment.currentText() == "test_env" qtbot.waitUntil( @@ -262,7 +261,7 @@ def test_environment_package_installation(spyder_env_manager, qtbot, caplog): qtbot.waitUntil( lambda: widget.packages_table.source_model.rowCount() == 3, - timeout=LONG_OPERATION_TIMEOUT, + timeout=OPERATION_TIMEOUT, ) assert widget.packages_table.get_package_info(0)["name"] == "packaging" assert widget.packages_table.get_package_info(0)["version"] == "22.0" From 007f48a7c44044b95cfc87c08fd2ecdce349bbe2 Mon Sep 17 00:00:00 2001 From: dalthviz Date: Tue, 28 Feb 2023 14:25:43 -0500 Subject: [PATCH 14/14] Testing --- spyder_env_manager/tests/test_plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spyder_env_manager/tests/test_plugin.py b/spyder_env_manager/tests/test_plugin.py index 45f047e..c3f28bd 100644 --- a/spyder_env_manager/tests/test_plugin.py +++ b/spyder_env_manager/tests/test_plugin.py @@ -32,7 +32,7 @@ ) # Constants -OPERATION_TIMEOUT = 60000 +OPERATION_TIMEOUT = 120000 IMPORT_FILE_PATH = str(Path(__file__).parent / "data" / "import_env.yml")