69
69
raise RuntimeError('I refuse to play nice')
72
class _NoImplementCompare(_Hashable):
74
def __eq__(self, other):
72
78
# Even though this is an extension, we don't permute the tests for a python
73
79
# version. As the plain python version is just a dict or set
329
335
# Tries to compare with k1, fails
330
336
self.assertRaises(RuntimeError, obj.add, k2)
338
def test_richcompare_not_implemented(self):
339
obj = self.module.SimpleSet()
340
# Even though their hashes are the same, tp_richcompare returns
341
# NotImplemented, which means we treat them as not equal
342
k1 = _NoImplementCompare(200)
343
k2 = _NoImplementCompare(200)
344
self.assertLookup(200, '<null>', obj, k1)
345
self.assertLookup(200, '<null>', obj, k2)
346
self.assertIs(k1, obj.add(k1))
347
self.assertLookup(200, k1, obj, k1)
348
self.assertLookup(201, '<null>', obj, k2)
349
self.assertIs(k2, obj.add(k2))
350
self.assertIs(k1, obj[k1])
332
352
def test_add_and_remove_lots_of_items(self):
333
353
obj = self.module.SimpleSet()
334
354
chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890'