@@ -178,6 +178,15 @@ def test_boxplot_stats_autorange_false(self):
178178 assert_array_almost_equal (bstats_true [0 ]['fliers' ], [])
179179
180180
181+ class Hashable :
182+ def dummy (self ): pass
183+
184+
185+ class Unhashable :
186+ __hash__ = None
187+ def dummy (self ): pass
188+
189+
181190class Test_callback_registry :
182191 def setup_method (self ):
183192 self .signal = 'test'
@@ -200,22 +209,23 @@ def count(self):
200209
201210 def is_empty (self ):
202211 np .testing .break_cycles ()
203- assert self .callbacks ._func_cid_map == {}
212+ assert [ * self .callbacks ._func_cid_map ] == []
204213 assert self .callbacks .callbacks == {}
205214 assert self .callbacks ._pickled_cids == set ()
206215
207216 def is_not_empty (self ):
208217 np .testing .break_cycles ()
209- assert self .callbacks ._func_cid_map != {}
218+ assert [ * self .callbacks ._func_cid_map ] != []
210219 assert self .callbacks .callbacks != {}
211220
212221 @pytest .mark .parametrize ('pickle' , [True , False ])
213- def test_callback_complete (self , pickle ):
222+ @pytest .mark .parametrize ('cls' , [Hashable , Unhashable ])
223+ def test_callback_complete (self , pickle , cls ):
214224 # ensure we start with an empty registry
215225 self .is_empty ()
216226
217227 # create a class for testing
218- mini_me = Test_callback_registry ()
228+ mini_me = cls ()
219229
220230 # test that we can add a callback
221231 cid1 = self .connect (self .signal , mini_me .dummy , pickle )
@@ -226,7 +236,7 @@ def test_callback_complete(self, pickle):
226236 cid2 = self .connect (self .signal , mini_me .dummy , pickle )
227237 assert cid1 == cid2
228238 self .is_not_empty ()
229- assert len (self .callbacks ._func_cid_map ) == 1
239+ assert len ([ * self .callbacks ._func_cid_map ] ) == 1
230240 assert len (self .callbacks .callbacks ) == 1
231241
232242 del mini_me
@@ -235,12 +245,13 @@ def test_callback_complete(self, pickle):
235245 self .is_empty ()
236246
237247 @pytest .mark .parametrize ('pickle' , [True , False ])
238- def test_callback_disconnect (self , pickle ):
248+ @pytest .mark .parametrize ('cls' , [Hashable , Unhashable ])
249+ def test_callback_disconnect (self , pickle , cls ):
239250 # ensure we start with an empty registry
240251 self .is_empty ()
241252
242253 # create a class for testing
243- mini_me = Test_callback_registry ()
254+ mini_me = cls ()
244255
245256 # test that we can add a callback
246257 cid1 = self .connect (self .signal , mini_me .dummy , pickle )
@@ -253,12 +264,13 @@ def test_callback_disconnect(self, pickle):
253264 self .is_empty ()
254265
255266 @pytest .mark .parametrize ('pickle' , [True , False ])
256- def test_callback_wrong_disconnect (self , pickle ):
267+ @pytest .mark .parametrize ('cls' , [Hashable , Unhashable ])
268+ def test_callback_wrong_disconnect (self , pickle , cls ):
257269 # ensure we start with an empty registry
258270 self .is_empty ()
259271
260272 # create a class for testing
261- mini_me = Test_callback_registry ()
273+ mini_me = cls ()
262274
263275 # test that we can add a callback
264276 cid1 = self .connect (self .signal , mini_me .dummy , pickle )
@@ -271,20 +283,21 @@ def test_callback_wrong_disconnect(self, pickle):
271283 self .is_not_empty ()
272284
273285 @pytest .mark .parametrize ('pickle' , [True , False ])
274- def test_registration_on_non_empty_registry (self , pickle ):
286+ @pytest .mark .parametrize ('cls' , [Hashable , Unhashable ])
287+ def test_registration_on_non_empty_registry (self , pickle , cls ):
275288 # ensure we start with an empty registry
276289 self .is_empty ()
277290
278291 # setup the registry with a callback
279- mini_me = Test_callback_registry ()
292+ mini_me = cls ()
280293 self .connect (self .signal , mini_me .dummy , pickle )
281294
282295 # Add another callback
283- mini_me2 = Test_callback_registry ()
296+ mini_me2 = cls ()
284297 self .connect (self .signal , mini_me2 .dummy , pickle )
285298
286299 # Remove and add the second callback
287- mini_me2 = Test_callback_registry ()
300+ mini_me2 = cls ()
288301 self .connect (self .signal , mini_me2 .dummy , pickle )
289302
290303 # We still have 2 references
@@ -296,9 +309,6 @@ def test_registration_on_non_empty_registry(self, pickle):
296309 mini_me2 = None
297310 self .is_empty ()
298311
299- def dummy (self ):
300- pass
301-
302312 def test_pickling (self ):
303313 assert hasattr (pickle .loads (pickle .dumps (cbook .CallbackRegistry ())),
304314 "callbacks" )
0 commit comments