diff options
author | Raymond Hettinger <python@rcn.com> | 2011-05-03 18:01:32 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2011-05-03 18:01:32 (GMT) |
commit | 003be529323a395be4a17c779aff7e4737170bbf (patch) | |
tree | 77277ef2fa91c41d4beed7dd1f4b2dc9da1f26ae /Lib/test | |
parent | 5098d44354d612445aa2dd97a304ed0c0660f236 (diff) | |
download | cpython-003be529323a395be4a17c779aff7e4737170bbf.zip cpython-003be529323a395be4a17c779aff7e4737170bbf.tar.gz cpython-003be529323a395be4a17c779aff7e4737170bbf.tar.bz2 |
Fix __hash__ in functools.cmp_to_key() to work with collections.Hashable.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_functools.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py index 73a77d6..7d11b53 100644 --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -1,4 +1,5 @@ import functools +import collections import sys import unittest from test import support @@ -446,7 +447,8 @@ class TestCmpToKey(unittest.TestCase): return y - x key = functools.cmp_to_key(mycmp) k = key(10) - self.assertRaises(TypeError, hash(k)) + self.assertRaises(TypeError, hash, k) + self.assertFalse(isinstance(k, collections.Hashable)) class TestTotalOrdering(unittest.TestCase): @@ -660,6 +662,7 @@ def test_main(verbose=None): TestPythonPartial, TestUpdateWrapper, TestTotalOrdering, + TestCmpToKey, TestWraps, TestReduce, TestLRU, |