Skip to content

Commit 8ff029c

Browse files
committed
Adds tests
1 parent a4cdebf commit 8ff029c

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/sas/qtgui/Plotting/UnitTesting/SlicerModelTest.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,27 @@ def testSetParamsFromModel(self, model):
6464
# Check the new model. The update should be automatic
6565
assert model.model().rowCount() == 3
6666
assert model.model().columnCount() == 2
67+
68+
69+
def testSetModelFromParams_blocks_itemChanged(self, model):
70+
"""Programmatic model writes should not emit itemChanged."""
71+
emissions = []
72+
model.model().itemChanged.connect(lambda *args: emissions.append(args))
73+
74+
model.setModelFromParams()
75+
76+
assert emissions == []
77+
78+
def testSetModelFromParams_restores_signal_state_on_exception(self, model, monkeypatch):
79+
"""Signal blocking should be restored even if model population fails."""
80+
def boom(value):
81+
if value == 2:
82+
raise RuntimeError("boom")
83+
return str(value)
84+
85+
monkeypatch.setattr("sas.qtgui.Plotting.SlicerModel.GuiUtils.formatNumber", boom)
86+
87+
with pytest.raises(RuntimeError):
88+
model.setModelFromParams()
89+
90+
assert model.model().signalsBlocked() is False

0 commit comments

Comments
 (0)