mirror of
https://github.com/python/cpython.git
synced 2025-10-09 08:31:26 +00:00
bpo-34149: Behavior of the min/max with key=None (GH-8328)
Improve consistency with the signature for sorted(), heapq.nsmallest(), heapq.nlargest(), and itertools.groupby().
This commit is contained in:
parent
bde782bb59
commit
e22072fb11
5 changed files with 17 additions and 8 deletions
|
@ -905,6 +905,8 @@ class BuiltinTest(unittest.TestCase):
|
|||
self.assertEqual(max((), default=1, key=neg), 1)
|
||||
self.assertEqual(max((1, 2), default=3, key=neg), 1)
|
||||
|
||||
self.assertEqual(max((1, 2), key=None), 2)
|
||||
|
||||
data = [random.randrange(200) for i in range(100)]
|
||||
keys = dict((elem, random.randrange(50)) for elem in data)
|
||||
f = keys.__getitem__
|
||||
|
@ -957,6 +959,8 @@ class BuiltinTest(unittest.TestCase):
|
|||
self.assertEqual(min((), default=1, key=neg), 1)
|
||||
self.assertEqual(min((1, 2), default=1, key=neg), 2)
|
||||
|
||||
self.assertEqual(min((1, 2), key=None), 1)
|
||||
|
||||
data = [random.randrange(200) for i in range(100)]
|
||||
keys = dict((elem, random.randrange(50)) for elem in data)
|
||||
f = keys.__getitem__
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue