File tree Expand file tree Collapse file tree
src/sas/qtgui/Plotting/UnitTesting Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments