mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
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.
This commit is contained in:
parent
4f185228b0
commit
bb006cf26c
8 changed files with 17 additions and 31 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue