Skip to content

Commit a1f0bc6

Browse files
authored
ci: Fix tests for napari from repository (#1148)
<!-- 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 -->
1 parent e734ebe commit a1f0bc6

File tree

7 files changed

+37
-20
lines changed

7 files changed

+37
-20
lines changed

.github/workflows/test_napari_repo.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ on:
55
- cron: '0 10 * * 1,3,5' # every 24 hours
66
# Allows you to run this workflow manually from the Actions tab
77
workflow_dispatch:
8+
pull_request:
9+
paths:
10+
- '.github/workflows/test_napari_repo.yml'
11+
- pyproject.toml
12+
- tox.ini
813

914
jobs:
1015
download_data:
@@ -29,7 +34,7 @@ jobs:
2934
fail-fast: false
3035
matrix:
3136
platform: [ ubuntu-22.04 ]
32-
python: ['3.8', '3.9' , '3.10', '3.11']
37+
python: ['3.9' , '3.10', '3.11', '3.12']
3338
napari_version: ['repo']
3439
steps:
3540
- uses: actions/checkout@v4

.github/workflows/test_napari_widgets.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
with:
2828
python_version: "3.10"
2929
os: ${{ matrix.os }}
30-
napari: "napari419"
30+
napari: "napari5"
3131
qt_backend: ${{ matrix.qt_backend }}
3232
timeout: 10
3333

package/PartSeg/common_gui/colormap_creator.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,8 @@ class for preview single colormap. Witch checkbox for change selection.
381381

382382
selection_changed = Signal(str, bool)
383383
"""checkbox selection changed (name)"""
384-
edit_request = Signal([str], [Colormap])
384+
edit_request_name = Signal(str)
385+
edit_request_colormap = Signal(Colormap)
385386
"""send after pressing edit signal (name) (ColorMap object)"""
386387
remove_request = Signal(str)
387388
"""Signal with name of colormap (name)"""
@@ -419,9 +420,9 @@ def __init__(
419420
layout.addWidget(self.label)
420421
self.setLayout(layout)
421422
self.checked.stateChanged.connect(self._selection_changed)
422-
self.edit_btn.clicked.connect(partial(self.edit_request.emit, name))
423+
self.edit_btn.clicked.connect(partial(self.edit_request_name.emit, name))
423424
if len(colormap.controls) < 20:
424-
self.edit_btn.clicked.connect(partial(self.edit_request[Colormap].emit, colormap))
425+
self.edit_btn.clicked.connect(partial(self.edit_request_colormap.emit, colormap))
425426
self.edit_btn.setToolTip("Create colormap base on this")
426427
else:
427428
self.edit_btn.setDisabled(True)
@@ -547,7 +548,7 @@ def refresh(self):
547548
cache_dict[el.name] = el
548549
else:
549550
el.deleteLater()
550-
el.edit_request[Colormap].disconnect()
551+
el.edit_request_colormap.disconnect()
551552
el.remove_request.disconnect()
552553
el.selection_changed.disconnect()
553554
selected = self.get_selected()
@@ -560,7 +561,7 @@ def refresh(self):
560561
widget.set_chosen(name in selected)
561562
else:
562563
widget = self._create_colormap_preview(colormap, name, removable)
563-
widget.edit_request[Colormap].connect(self.edit_signal)
564+
widget.edit_request_colormap.connect(self.edit_signal)
564565
widget.remove_request.connect(self._remove_request)
565566
widget.selection_changed.connect(self.change_selection)
566567
layout.addWidget(widget, i // columns, i % columns)

package/tests/conftest.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,16 @@ def pytest_collection_modifyitems(session, config, items):
279279
items[:] = image_tests + core_tests + other_test
280280

281281

282-
def pytest_runtest_setup(item):
282+
def pytest_runtest_setup(item): # pragma: no cover
283283
if platform.system() == "Windows" and any(item.iter_markers(name="windows_ci_skip")):
284284
pytest.skip("glBindFramebuffer with no OpenGL")
285285
if platform.system() == "Windows" and any(item.iter_markers(name="pyside_skip")):
286286
import qtpy
287287

288288
if qtpy.API_NAME == "PySide2":
289289
pytest.skip("PySide2 problems")
290+
if any(item.iter_markers(name="pyside6_skip")):
291+
import qtpy
292+
293+
if qtpy.API_NAME == "PySide6":
294+
pytest.skip("PySide6 problems")

package/tests/test_PartSeg/test_base_widgets.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def test_napari_viewer_additional_layers_empty(self, qtbot, part_settings, monke
106106
information_mock.assert_called_once()
107107

108108
@pytest.mark.windows_ci_skip()
109+
@pytest.mark.pyside6_skip()
109110
def test_napari_viewer_additional_layers(self, qtbot, part_settings, monkeypatch):
110111
main_window = BaseMainWindow(settings=part_settings)
111112
qtbot.addWidget(main_window)

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ markers = [
205205
"enabledialog: Allow to use dialog in test",
206206
"no_patch_add_layer: Do not patch napari viewer",
207207
"windows_ci_skip: Skip test when running on windows CI",
208-
"pyside_skip: Skip test when using pyside qt backend",
208+
"pyside_skip: Skip test when using pyside2 qt backend",
209+
"pyside6_skip: Skip test when using pyside6 qt backend"
209210
]
210211

211212
[tool.coverage.paths]

tox.ini

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# and then run "tox" from this directory.
55

66
[tox]
7-
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}
7+
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}
88
toxworkdir=/tmp/tox
99

1010
[gh-actions]
@@ -22,6 +22,7 @@ NAPARI =
2222
napari417: napari_417
2323
napari418: napari_418
2424
napari419: napari_419
25+
napari5: napari_5
2526
repo: napari_repo
2627
BACKEND =
2728
pyqt: PyQt5
@@ -39,7 +40,8 @@ deps =
3940
PySide2: PySide2!=5.15.0
4041
PyQt6: PyQt6
4142
# fix PySide6 when a new napari release is out
42-
PySide6: PySide6<6.3.2
43+
PySide6: PySide6<6.3.2; python_version < "3.10"
44+
PySide6: PySide6; python_version >= "3.10"
4345
PySide2: npe2!=0.2.2
4446
imageio != 2.22.1
4547
pytest-json-report
@@ -71,18 +73,20 @@ deps=
7173
pytest-json-report
7274
lxml_html_clean
7375

74-
[testenv:py{38,39,310,311,312}-{PyQt5,PySide2,PyQt6,PySide6}-napari_{417,418,419,repo}]
76+
[testenv:py{38,39,310,311,312}-{PyQt5,PySide2,PyQt6,PySide6}-napari_{417,418,419,5,repo}]
7577
deps =
7678
{[testenv]deps}
77-
417: napari==0.4.17
78-
417: pydantic<2
79-
418: napari==0.4.18
80-
418: pydantic<2
81-
419: napari==0.4.19.post1
82-
repo: git+https://github.com/napari/napari.git
79+
napari_417: napari==0.4.17
80+
napari_417: pydantic<2
81+
napari_418: napari==0.4.18
82+
napari_418: pydantic<2
83+
napari_419: napari==0.4.19.post1
84+
napari_5: napari==0.5.0
85+
napari_repo: git+https://github.com/napari/napari.git
86+
numpy<2
8387
commands =
84-
!repo: python -m pytest -v package/tests/test_PartSeg/test_napari_widgets.py --json-report --json-report-file={toxinidir}/report-{envname}-{sys_platform}.json
85-
repo: python -m pytest --json-report --json-report-file={toxinidir}/report-{envname}-{sys_platform}.json
88+
!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
89+
napari_repo: python -m pytest package/tests --json-report --json-report-file={toxinidir}/report-{envname}-{sys_platform}.json
8690

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

0 commit comments

Comments
 (0)