Skip to content

Commit 80e44e4

Browse files
committed
proper skip for no matplotlib import
1 parent c8f1198 commit 80e44e4

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

tests/widgets/test_workflow_inspector.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,18 @@
77

88
import pytest
99

10+
from ndev_workflows.widgets._workflow_inspector import (
11+
HAS_MATPLOTLIB,
12+
WorkflowInspector,
13+
)
14+
1015

1116
class TestWorkflowInspector:
1217
"""Core WorkflowInspector widget tests."""
1318

1419
@pytest.fixture
1520
def inspector(self, make_napari_viewer, qtbot):
1621
"""Create a WorkflowInspector widget."""
17-
pytest.importorskip('matplotlib')
18-
pytest.importorskip('networkx')
19-
20-
from ndev_workflows.widgets._workflow_inspector import (
21-
WorkflowInspector,
22-
)
23-
2422
viewer = make_napari_viewer()
2523
widget = WorkflowInspector(viewer)
2624
qtbot.addWidget(widget)
@@ -96,6 +94,7 @@ def identity(x):
9694
assert inspector._use_live_mode is True
9795
assert inspector._loaded_workflow is None
9896

97+
@pytest.mark.skipif(not HAS_MATPLOTLIB, reason='requires matplotlib')
9998
def test_graph_updates_on_workflow_load(self, inspector, tmp_path):
10099
"""Test that graph is drawn when workflow is loaded."""
101100
from ndev_workflows import Workflow, save_workflow
@@ -210,13 +209,13 @@ def test_pending_updates_property(self, make_napari_viewer):
210209
assert 'modified' not in manager.pending_updates
211210

212211

212+
@pytest.mark.skipif(not HAS_MATPLOTLIB, reason='requires matplotlib')
213213
class TestDraggableNodes:
214-
"""Test DraggableNodes interaction handling."""
214+
"""Test DraggableNodes interaction handling (requires matplotlib)."""
215215

216216
@pytest.fixture
217217
def draggable_nodes(self):
218218
"""Create DraggableNodes with real MplCanvas."""
219-
pytest.importorskip('matplotlib')
220219
from unittest.mock import MagicMock
221220

222221
from ndev_workflows.widgets._workflow_inspector import (
@@ -272,7 +271,6 @@ def test_update_node_status_changes_color(self, draggable_nodes):
272271

273272
def test_select_node_with_viewer(self, make_napari_viewer):
274273
"""Test clicking a node selects the layer in viewer."""
275-
pytest.importorskip('matplotlib')
276274
import numpy as np
277275

278276
from ndev_workflows.widgets._workflow_inspector import (

0 commit comments

Comments
 (0)