Skip to content

Commit

Permalink
ci: Fix tests for napari from repository (#1148)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
  - Added support for `napari` version 0.5.0.
  - Introduced new environment configuration for `napari5`.

- **Bug Fixes**
- Updated test configurations to ensure compatibility with `PySide6` and
other Python versions.
  - Improved handling of `edit_request` signals in the Colormap Creator.

- **Chores**
  - Adjusted GitHub workflow triggers and updated Python version matrix.
- Refined test skipping markers for `PySide6` to enhance test
management.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
Czaki authored Jul 17, 2024
1 parent e734ebe commit a1f0bc6
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 20 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/test_napari_repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ on:
- cron: '0 10 * * 1,3,5' # every 24 hours
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
pull_request:
paths:
- '.github/workflows/test_napari_repo.yml'
- pyproject.toml
- tox.ini

jobs:
download_data:
Expand All @@ -29,7 +34,7 @@ jobs:
fail-fast: false
matrix:
platform: [ ubuntu-22.04 ]
python: ['3.8', '3.9' , '3.10', '3.11']
python: ['3.9' , '3.10', '3.11', '3.12']
napari_version: ['repo']
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_napari_widgets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
with:
python_version: "3.10"
os: ${{ matrix.os }}
napari: "napari419"
napari: "napari5"
qt_backend: ${{ matrix.qt_backend }}
timeout: 10

Expand Down
11 changes: 6 additions & 5 deletions package/PartSeg/common_gui/colormap_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,8 @@ class for preview single colormap. Witch checkbox for change selection.

selection_changed = Signal(str, bool)
"""checkbox selection changed (name)"""
edit_request = Signal([str], [Colormap])
edit_request_name = Signal(str)
edit_request_colormap = Signal(Colormap)
"""send after pressing edit signal (name) (ColorMap object)"""
remove_request = Signal(str)
"""Signal with name of colormap (name)"""
Expand Down Expand Up @@ -419,9 +420,9 @@ def __init__(
layout.addWidget(self.label)
self.setLayout(layout)
self.checked.stateChanged.connect(self._selection_changed)
self.edit_btn.clicked.connect(partial(self.edit_request.emit, name))
self.edit_btn.clicked.connect(partial(self.edit_request_name.emit, name))
if len(colormap.controls) < 20:
self.edit_btn.clicked.connect(partial(self.edit_request[Colormap].emit, colormap))
self.edit_btn.clicked.connect(partial(self.edit_request_colormap.emit, colormap))
self.edit_btn.setToolTip("Create colormap base on this")
else:
self.edit_btn.setDisabled(True)
Expand Down Expand Up @@ -547,7 +548,7 @@ def refresh(self):
cache_dict[el.name] = el
else:
el.deleteLater()
el.edit_request[Colormap].disconnect()
el.edit_request_colormap.disconnect()
el.remove_request.disconnect()
el.selection_changed.disconnect()
selected = self.get_selected()
Expand All @@ -560,7 +561,7 @@ def refresh(self):
widget.set_chosen(name in selected)
else:
widget = self._create_colormap_preview(colormap, name, removable)
widget.edit_request[Colormap].connect(self.edit_signal)
widget.edit_request_colormap.connect(self.edit_signal)
widget.remove_request.connect(self._remove_request)
widget.selection_changed.connect(self.change_selection)
layout.addWidget(widget, i // columns, i % columns)
Expand Down
7 changes: 6 additions & 1 deletion package/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,16 @@ def pytest_collection_modifyitems(session, config, items):
items[:] = image_tests + core_tests + other_test


def pytest_runtest_setup(item):
def pytest_runtest_setup(item): # pragma: no cover
if platform.system() == "Windows" and any(item.iter_markers(name="windows_ci_skip")):
pytest.skip("glBindFramebuffer with no OpenGL")
if platform.system() == "Windows" and any(item.iter_markers(name="pyside_skip")):
import qtpy

if qtpy.API_NAME == "PySide2":
pytest.skip("PySide2 problems")
if any(item.iter_markers(name="pyside6_skip")):
import qtpy

if qtpy.API_NAME == "PySide6":
pytest.skip("PySide6 problems")
1 change: 1 addition & 0 deletions package/tests/test_PartSeg/test_base_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def test_napari_viewer_additional_layers_empty(self, qtbot, part_settings, monke
information_mock.assert_called_once()

@pytest.mark.windows_ci_skip()
@pytest.mark.pyside6_skip()
def test_napari_viewer_additional_layers(self, qtbot, part_settings, monkeypatch):
main_window = BaseMainWindow(settings=part_settings)
qtbot.addWidget(main_window)
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ markers = [
"enabledialog: Allow to use dialog in test",
"no_patch_add_layer: Do not patch napari viewer",
"windows_ci_skip: Skip test when running on windows CI",
"pyside_skip: Skip test when using pyside qt backend",
"pyside_skip: Skip test when using pyside2 qt backend",
"pyside6_skip: Skip test when using pyside6 qt backend"
]

[tool.coverage.paths]
Expand Down
26 changes: 15 additions & 11 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# and then run "tox" from this directory.

[tox]
envlist = py{38,39,310,311,312}-{PyQt5,PySide2,PyQt6,PySide6}-all, py{38,39,310,311,312}-{PyQt5,PySide2,PyQt6,PySide6}-napari_{417,418,419,repo}
envlist = py{38,39,310,311,312}-{PyQt5,PySide2,PyQt6,PySide6}-all, py{39,310,311,312}-{PyQt5,PyQt6}-napari_{417,418,419,5,repo}, py{39,310}-PySide2-napari_{417,418,419,5,repo}
toxworkdir=/tmp/tox

[gh-actions]
Expand All @@ -22,6 +22,7 @@ NAPARI =
napari417: napari_417
napari418: napari_418
napari419: napari_419
napari5: napari_5
repo: napari_repo
BACKEND =
pyqt: PyQt5
Expand All @@ -39,7 +40,8 @@ deps =
PySide2: PySide2!=5.15.0
PyQt6: PyQt6
# fix PySide6 when a new napari release is out
PySide6: PySide6<6.3.2
PySide6: PySide6<6.3.2; python_version < "3.10"
PySide6: PySide6; python_version >= "3.10"
PySide2: npe2!=0.2.2
imageio != 2.22.1
pytest-json-report
Expand Down Expand Up @@ -71,18 +73,20 @@ deps=
pytest-json-report
lxml_html_clean

[testenv:py{38,39,310,311,312}-{PyQt5,PySide2,PyQt6,PySide6}-napari_{417,418,419,repo}]
[testenv:py{38,39,310,311,312}-{PyQt5,PySide2,PyQt6,PySide6}-napari_{417,418,419,5,repo}]
deps =
{[testenv]deps}
417: napari==0.4.17
417: pydantic<2
418: napari==0.4.18
418: pydantic<2
419: napari==0.4.19.post1
repo: git+https://github.com/napari/napari.git
napari_417: napari==0.4.17
napari_417: pydantic<2
napari_418: napari==0.4.18
napari_418: pydantic<2
napari_419: napari==0.4.19.post1
napari_5: napari==0.5.0
napari_repo: git+https://github.com/napari/napari.git
numpy<2
commands =
!repo: python -m pytest -v package/tests/test_PartSeg/test_napari_widgets.py --json-report --json-report-file={toxinidir}/report-{envname}-{sys_platform}.json
repo: python -m pytest --json-report --json-report-file={toxinidir}/report-{envname}-{sys_platform}.json
!napari_repo: python -m pytest -v package/tests/test_PartSeg/test_napari_widgets.py --json-report --json-report-file={toxinidir}/report-{envname}-{sys_platform}.json
napari_repo: python -m pytest package/tests --json-report --json-report-file={toxinidir}/report-{envname}-{sys_platform}.json

[testenv:py{38,39,310,311,312}-PyQt5-coverage]
deps =
Expand Down

0 comments on commit a1f0bc6

Please sign in to comment.