@@ -101,8 +101,19 @@ def test_cmap_combo(qtbot, filterable):
101101 return # the rest fails on CI... but works locally
102102
103103 # click the Add Colormap... item
104+ # NOTE: We wrap __init__ instead of patching exec directly because
105+ # PySide6 6.10 crashes when MetaObjectBuilder inspects mocked methods
106+ # during signal connection (parsePythonType segfault)
107+ _original_init = _cmap_combo ._CmapNameDialog .__init__
108+
109+ def _init_with_mock_exec (self , * args , ** kwargs ):
110+ _original_init (self , * args , ** kwargs )
111+ self .exec = lambda : True
112+
104113 with qtbot .waitSignal (wdg .currentColormapChanged ):
105- with patch .object (_cmap_combo ._CmapNameDialog , "exec" , return_value = True ):
114+ with patch .object (
115+ _cmap_combo ._CmapNameDialog , "__init__" , _init_with_mock_exec
116+ ):
106117 wdg ._on_activated (wdg .count () - 1 )
107118
108119 assert wdg .count () == 5
@@ -111,7 +122,13 @@ def test_cmap_combo(qtbot, filterable):
111122 assert wdg .itemColormap (3 ).name .split (":" )[- 1 ] == "accent"
112123
113124 # click the Add Colormap... item, but cancel the dialog
114- with patch .object (_cmap_combo ._CmapNameDialog , "exec" , return_value = False ):
125+ def _init_with_mock_exec_false (self , * args , ** kwargs ):
126+ _original_init (self , * args , ** kwargs )
127+ self .exec = lambda : False
128+
129+ with patch .object (
130+ _cmap_combo ._CmapNameDialog , "__init__" , _init_with_mock_exec_false
131+ ):
115132 wdg ._on_activated (wdg .count () - 1 )
116133
117134
0 commit comments