diff options
author | Raymond Hettinger <python@rcn.com> | 2010-04-04 21:45:01 +0000 |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2010-04-04 21:45:01 +0000 |
commit | bb006cf26cc41aefcddc8f06722c524826aacefa (patch) | |
tree | 5d0e82402052f188ea868cf94497eba52a7b38fd /Lib/test/test_functools.py | |
parent | 4f185228b084ee45ef822198762154457dc343db (diff) | |
download | cpython-git-bb006cf26cc41aefcddc8f06722c524826aacefa.tar.gz |
Add tests for cmp_to_key.
Adopt PEP 8 compliant function name.
Factor-out existing uses cmp_to_key.
Update documentation to use internal pointers instead of external resource.
Diffstat (limited to 'Lib/test/test_functools.py')
-rw-r--r-- | Lib/test/test_functools.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py index 2549e05c14..44992b8c5b 100644 --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -338,7 +338,12 @@ class TestReduce(unittest.TestCase): self.assertEqual(reduce(42, "", "1"), "1") # func is never called with one item self.assertRaises(TypeError, reduce, 42, (42, 42)) - +class TestCmpToKey(unittest.TestCase): + def test_cmp_to_key(self): + def mycmp(x, y): + return y - x + self.assertEqual(sorted(range(5), key=functools.cmp_to_key(mycmp)), + [4, 3, 2, 1, 0]) def test_main(verbose=None): |