mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-39200: Correct the error message for min/max builtin function (GH-17814)
Correct the error message when calling the min() or max() with no arguments.
This commit is contained in:
parent
c39b52f152
commit
abdc634f33
3 changed files with 21 additions and 4 deletions
|
@ -949,7 +949,12 @@ class BuiltinTest(unittest.TestCase):
|
|||
self.assertEqual(max(1, 2.0, 3), 3)
|
||||
self.assertEqual(max(1.0, 2, 3), 3)
|
||||
|
||||
self.assertRaises(TypeError, max)
|
||||
with self.assertRaisesRegex(
|
||||
TypeError,
|
||||
'max expected at least 1 argument, got 0'
|
||||
):
|
||||
max()
|
||||
|
||||
self.assertRaises(TypeError, max, 42)
|
||||
self.assertRaises(ValueError, max, ())
|
||||
class BadSeq:
|
||||
|
@ -1003,7 +1008,12 @@ class BuiltinTest(unittest.TestCase):
|
|||
self.assertEqual(min(1, 2.0, 3), 1)
|
||||
self.assertEqual(min(1.0, 2, 3), 1.0)
|
||||
|
||||
self.assertRaises(TypeError, min)
|
||||
with self.assertRaisesRegex(
|
||||
TypeError,
|
||||
'min expected at least 1 argument, got 0'
|
||||
):
|
||||
min()
|
||||
|
||||
self.assertRaises(TypeError, min, 42)
|
||||
self.assertRaises(ValueError, min, ())
|
||||
class BadSeq:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue