mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
bpo-39200: Correct the error message for range() empty constructor (GH-17813)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
b121a4a45f
commit
4b66fa6ce9
3 changed files with 58 additions and 28 deletions
|
@ -91,6 +91,19 @@ class RangeTest(unittest.TestCase):
|
|||
r = range(-sys.maxsize, sys.maxsize, 2)
|
||||
self.assertEqual(len(r), sys.maxsize)
|
||||
|
||||
def test_range_constructor_error_messages(self):
|
||||
with self.assertRaisesRegex(
|
||||
TypeError,
|
||||
"range expected at least 1 argument, got 0"
|
||||
):
|
||||
range()
|
||||
|
||||
with self.assertRaisesRegex(
|
||||
TypeError,
|
||||
"range expected at most 3 arguments, got 6"
|
||||
):
|
||||
range(1, 2, 3, 4, 5, 6)
|
||||
|
||||
def test_large_operands(self):
|
||||
x = range(10**20, 10**20+10, 3)
|
||||
self.assertEqual(len(x), 4)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue