Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Compatibility fixes for Spyder 6.0.0 alpha 5 #222

Merged
merged 7 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .github/scripts/generate-without-spyder.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@
"""Script to generate requirements/without-spyder.txt"""

import re
from pathlib import Path

with open('requirements/conda.txt') as infile:
with open('requirements/without-spyder.txt', 'w') as outfile:
rootdir = Path(__file__).parents[2]
input_filename = rootdir / 'requirements' / 'conda.txt'
output_filename = rootdir / 'requirements' / 'without-spyder.txt'

with open(input_filename) as infile:
with open(output_filename, 'w') as outfile:
for line in infile:
package_name = re.match('[-a-z0-9_]*', line).group(0)
if package_name != 'spyder':
outfile.write(line)

32 changes: 17 additions & 15 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,23 @@ jobs:
PYTHON_VERSION: ${{ matrix.PYTHON_VERSION }}
steps:
- name: Checkout branch
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: 'spyder-unittest'
- name: Install System Packages
if: matrix.OS == 'ubuntu'
run: |
sudo apt-get update --fix-missing
sudo apt-get install -qq pyqt5-dev-tools libxcb-xinerama0 xterm --fix-missing
- name: Install Conda
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
miniforge-version: latest
auto-update-conda: true
python-version: ${{ matrix.PYTHON_VERSION }}
- name: Checkout Spyder from git
if: matrix.SPYDER_SOURCE == 'git'
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: 'spyder-ide/spyder'
path: 'spyder'
Expand All @@ -64,49 +66,49 @@ jobs:
if: matrix.SPYDER_SOURCE == 'git'
shell: bash -l {0}
run: |
python .github/scripts/generate-without-spyder.py
mamba install --file requirements/without-spyder.txt -y
python spyder-unittest/.github/scripts/generate-without-spyder.py
mamba install --file spyder-unittest/requirements/without-spyder.txt -y
- name: Install plugin dependencies
if: matrix.SPYDER_SOURCE == 'conda'
shell: bash -l {0}
run: mamba install --file requirements/conda.txt -y
run: mamba install --file spyder-unittest/requirements/conda.txt -y
- name: Install test dependencies
shell: bash -l {0}
run: |
mamba install nomkl -y -q
mamba install --file requirements/tests.txt -y
mamba install --file spyder-unittest/requirements/tests.txt -y
- name: Install plugin
shell: bash -l {0}
run: pip install --no-deps -e .
run: pip install --no-deps -e spyder-unittest
- name: Show environment information
shell: bash -l {0}
run: |
mamba info
mamba list
- name: Run tests (Linux)
if: matrix.OS == 'ubuntu'
uses: nick-fields/retry@v2
uses: nick-fields/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
shell: bash
command: |
. ~/.profile
xvfb-run --auto-servernum pytest spyder_unittest -vv
xvfb-run --auto-servernum pytest spyder-unittest/spyder_unittest -vv
- name: Run tests (MacOS)
if: matrix.OS == 'macos'
uses: nick-fields/retry@v2
uses: nick-fields/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
shell: bash
command: |
. ~/.profile
pytest spyder_unittest -vv
pytest spyder-unittest/spyder_unittest -vv
- name: Run tests (Windows)
if: matrix.OS == 'windows'
uses: nick-fields/retry@v2
uses: nick-fields/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
command: pytest spyder_unittest -vv
command: pytest spyder-unittest/spyder_unittest -vv
19 changes: 14 additions & 5 deletions spyder_unittest/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
available for integration tests.
"""

# Standard library imports
import os

# Third-party imports
from qtpy.QtWidgets import QApplication
import pytest
Expand All @@ -19,7 +22,6 @@
from qtpy import QtWebEngineWidgets # noqa

# Spyder imports
from spyder import dependencies
from spyder import version_info as spyder_version_info
from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY
from spyder.app import start
Expand All @@ -39,11 +41,13 @@ def main_window(monkeypatch):

# Don't show tours message
CONF.set('tours', 'show_tour_message', False)
QApplication.processEvents()

# Reset global state
dependencies.DEPENDENCIES = []
PLUGIN_REGISTRY.reset()
# Turn introspection on, even though it's slower and more memory
# intensive, because otherwise tests are aborted at end with
# "QThread: Destroyed while thread is still running".
os.environ['SPY_TEST_USE_INTROSPECTION'] = 'True'

QApplication.processEvents()

# Start the window
window = start.main()
Expand All @@ -52,5 +56,10 @@ def main_window(monkeypatch):
yield window

# Close main window
window.closing(close_immediately=True)
window.close()
CONF.reset_to_defaults(notification=False)
CONF.reset_manager()
PLUGIN_REGISTRY.reset()

os.environ.pop('SPY_TEST_USE_INTROSPECTION')
4 changes: 2 additions & 2 deletions spyder_unittest/unittestplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ def on_editor_available(self):
"""
editor = self.get_plugin(Plugins.Editor)
run_action = self.get_action(UnitTestPluginActions.Run)
editor.pythonfile_dependent_actions += [run_action]
editor.get_widget().pythonfile_dependent_actions += [run_action]
# FIXME: Previous line does not do anything
self.get_widget().pre_test_hook = editor.save_all
self.get_widget().pre_test_hook = editor.get_widget().save_all
self.get_widget().sig_edit_goto.connect(self.goto_in_editor)

@on_plugin_teardown(plugin=Plugins.Editor)
Expand Down
6 changes: 3 additions & 3 deletions spyder_unittest/widgets/datatree.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from qtpy.QtWidgets import QMenu, QTreeView
from spyder.api.config.mixins import SpyderConfigurationAccessor
from spyder.config.base import get_translation
from spyder.utils.palette import QStylePalette, SpyderPalette
from spyder.utils.palette import SpyderPalette
from spyder.utils.qthelpers import create_action

# Local imports
Expand All @@ -33,8 +33,8 @@
Category.OK: SpyderPalette.COLOR_SUCCESS_1,
Category.FAIL: SpyderPalette.COLOR_ERROR_1,
Category.SKIP: SpyderPalette.COLOR_WARN_1,
Category.PENDING: QStylePalette.COLOR_BACKGROUND_1,
Category.COVERAGE: QStylePalette.COLOR_ACCENT_1
Category.PENDING: SpyderPalette.COLOR_BACKGROUND_1,
Category.COVERAGE: SpyderPalette.COLOR_ACCENT_1
}

STATUS_COLUMN = 0
Expand Down
9 changes: 8 additions & 1 deletion spyder_unittest/widgets/tests/test_confpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY
from spyder.app.cli_options import get_options
from spyder.config.manager import CONF
from spyder.plugins.preferences.plugin import Preferences

# Local imports
from spyder_unittest.unittestplugin import UnitTestPlugin
Expand All @@ -34,6 +33,10 @@ class MainWindowMock(QMainWindow):
register_shortcut = Mock()

def __init__(self, parent):
# This import assumes that an QApplication is already running,
# so we can not put it at the top of the file
from spyder.plugins.preferences.plugin import Preferences

super().__init__(parent)
self.default_style = None
self.widgetlist = []
Expand Down Expand Up @@ -75,6 +78,10 @@ def get_plugin(self, plugin_name, error=True):
class ConfigDialogTester(QWidget):
def __init__(self, parent, main_class,
general_config_plugins, plugins):
# This import assumes that an QApplication is already running,
# so we can not put it at the top of the file
from spyder.plugins.preferences.plugin import Preferences

super().__init__(parent)
self._main = main_class(self) if main_class else None
if self._main is None:
Expand Down
Loading