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.
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py
index 2549e05..44992b8 100644
--- a/Lib/test/test_functools.py
+++ b/Lib/test/test_functools.py
@@ -338,7 +338,12 @@
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):