~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test__simple_set.py

  • Committer: John Arbash Meinel
  • Date: 2009-10-15 18:18:44 UTC
  • mfrom: (4748 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4749.
  • Revision ID: john@arbash-meinel.com-20091015181844-ame1y9yxta689ojp
Merge bzr.dev, resolve NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
        raise RuntimeError('I refuse to play nice')
70
70
 
71
71
 
 
72
class _NoImplementCompare(_Hashable):
 
73
 
 
74
    def __eq__(self, other):
 
75
        return NotImplemented
 
76
 
 
77
 
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
74
80
 
329
335
        # Tries to compare with k1, fails
330
336
        self.assertRaises(RuntimeError, obj.add, k2)
331
337
 
 
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])
 
351
 
332
352
    def test_add_and_remove_lots_of_items(self):
333
353
        obj = self.module.SimpleSet()
334
354
        chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890'