File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -351,7 +351,7 @@ def remove_callback(self, oid):
351351 --------
352352 add_callback
353353 """
354- self ._callbacks .disconnect ("pchanged" , oid )
354+ self ._callbacks .disconnect (oid )
355355
356356 def pchanged (self ):
357357 """
Original file line number Diff line number Diff line change @@ -303,3 +303,21 @@ def test_set_alpha_for_array():
303303 art ._set_alpha_for_array ([0.5 , 1.1 ])
304304 with pytest .raises (ValueError , match = "alpha must be between 0 and 1" ):
305305 art ._set_alpha_for_array ([0.5 , np .nan ])
306+
307+
308+ def test_callbacks ():
309+ def func (artist ):
310+ func .counter += 1
311+
312+ func .counter = 0
313+
314+ art = martist .Artist ()
315+ oid = art .add_callback (func )
316+ assert func .counter == 0
317+ art .pchanged () # must call the callback
318+ assert func .counter == 1
319+ art .set_zorder (10 ) # setting a property must also call the callback
320+ assert func .counter == 2
321+ art .remove_callback (oid )
322+ art .pchanged () # must not call the callback anymore
323+ assert func .counter == 2
You can’t perform that action at this time.
0 commit comments