diff options
author | Raymond Hettinger <python@rcn.com> | 2010-04-05 18:53:43 +0000 |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2010-04-05 18:53:43 +0000 |
commit | e1d665a90e4a20a60c0c9904417160ea3c7660b7 (patch) | |
tree | b70e4a64cd4a6a5ec6023fbe35069b4eb5af37fc /Lib/test/test_functools.py | |
parent | 5e0c2748fb2e16b3b0f33f0bb55f1aaa1272f887 (diff) | |
download | cpython-git-e1d665a90e4a20a60c0c9904417160ea3c7660b7.tar.gz |
Classes that override __eq__ also need to define __hash__.
Diffstat (limited to 'Lib/test/test_functools.py')
-rw-r--r-- | Lib/test/test_functools.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py index 1629f7ce4e..05e19b1399 100644 --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -345,6 +345,13 @@ class TestCmpToKey(unittest.TestCase): self.assertEqual(sorted(range(5), key=functools.cmp_to_key(mycmp)), [4, 3, 2, 1, 0]) + def test_hash(self): + def mycmp(x, y): + return y - x + key = functools.cmp_to_key(mycmp) + k = key(10) + self.assertRaises(TypeError, hash(k)) + class TestTotalOrdering(unittest.TestCase): def test_total_ordering_lt(self): |