~pythonregexp2.7/python/issue2636-09-01+10

« back to all changes in this revision

Viewing changes to Lib/test/test_descr.py

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-09-22 21:39:45 UTC
  • mfrom: (39055.1.33 Regexp-2.7)
  • Revision ID: darklord@timehorse.com-20080922213945-23717m5eiqpamcyn
Merged in changes from the Single-Loop Engine branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1121
1121
        class G(object):
1122
1122
            def __cmp__(self, other):
1123
1123
                return 0
 
1124
            __hash__ = None # Silence Py3k warning
1124
1125
        g = G()
1125
1126
        orig_objects = len(gc.get_objects())
1126
1127
        for i in xrange(10):
2727
2728
                    if isinstance(other, int) or isinstance(other, long):
2728
2729
                        return cmp(self.value, other)
2729
2730
                    return NotImplemented
 
2731
                __hash__ = None # Silence Py3k warning
2730
2732
 
2731
2733
            c1 = C(1)
2732
2734
            c2 = C(2)
2755
2757
                    return abs(self - other) <= 1e-6
2756
2758
                except:
2757
2759
                    return NotImplemented
 
2760
            __hash__ = None # Silence Py3k warning
2758
2761
        zz = ZZ(1.0000003)
2759
2762
        self.assertEqual(zz, 1+0j)
2760
2763
        self.assertEqual(1+0j, zz)
2767
2770
                    self.value = int(value)
2768
2771
                def __cmp__(self_, other):
2769
2772
                    self.fail("shouldn't call __cmp__")
 
2773
                __hash__ = None # Silence Py3k warning
2770
2774
                def __eq__(self, other):
2771
2775
                    if isinstance(other, C):
2772
2776
                        return self.value == other.value
3262
3266
        class S(str):
3263
3267
            def __eq__(self, other):
3264
3268
                return self.lower() == other.lower()
 
3269
            __hash__ = None # Silence Py3k warning
3265
3270
 
3266
3271
    def test_subclass_propagation(self):
3267
3272
        # Testing propagation of slot functions to subclasses...
3283
3288
        self.assertEqual(hash(d), 144)
3284
3289
        D.__hash__ = lambda self: 100
3285
3290
        self.assertEqual(hash(d), 100)
 
3291
        D.__hash__ = None
 
3292
        self.assertRaises(TypeError, hash, d)
3286
3293
        del D.__hash__
3287
3294
        self.assertEqual(hash(d), 144)
 
3295
        B.__hash__ = None
 
3296
        self.assertRaises(TypeError, hash, d)
3288
3297
        del B.__hash__
3289
3298
        self.assertEqual(hash(d), 314)
 
3299
        C.__hash__ = None
 
3300
        self.assertRaises(TypeError, hash, d)
3290
3301
        del C.__hash__
3291
3302
        self.assertEqual(hash(d), 42)
 
3303
        A.__hash__ = None
 
3304
        self.assertRaises(TypeError, hash, d)
3292
3305
        del A.__hash__
3293
3306
        self.assertEqual(hash(d), orig_hash)
3294
3307
        d.foo = 42