summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_descr.py
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2008-07-15 14:27:37 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2008-07-15 14:27:37 (GMT)
commit53663a695ef2bb96ac0252cd4cc4aa40d4f953be (patch)
treee241ef71b353f8b3162179b1eed5a3f4eaae0c5f /Lib/test/test_descr.py
parent9ace15ca25e1e72e1b943190a5f4efbd7d118de3 (diff)
downloadcpython-53663a695ef2bb96ac0252cd4cc4aa40d4f953be.zip
cpython-53663a695ef2bb96ac0252cd4cc4aa40d4f953be.tar.gz
cpython-53663a695ef2bb96ac0252cd4cc4aa40d4f953be.tar.bz2
Issue 2235: __hash__ is once again inherited by default, but inheritance can be blocked explicitly so that collections.Hashable remains meaningful
Diffstat (limited to 'Lib/test/test_descr.py')
-rw-r--r--Lib/test/test_descr.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 3c607f7..53b7611 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -3283,12 +3283,20 @@ order (MRO) for bases """
self.assertEqual(hash(d), 144)
D.__hash__ = lambda self: 100
self.assertEqual(hash(d), 100)
+ D.__hash__ = None
+ self.assertRaises(TypeError, hash, d)
del D.__hash__
self.assertEqual(hash(d), 144)
+ B.__hash__ = None
+ self.assertRaises(TypeError, hash, d)
del B.__hash__
self.assertEqual(hash(d), 314)
+ C.__hash__ = None
+ self.assertRaises(TypeError, hash, d)
del C.__hash__
self.assertEqual(hash(d), 42)
+ A.__hash__ = None
+ self.assertRaises(TypeError, hash, d)
del A.__hash__
self.assertEqual(hash(d), orig_hash)
d.foo = 42