Skip to content
Snippets Groups Projects
Commit dcd8f527 authored by Damien George's avatar Damien George
Browse files

tests/basics: Add tests for raising ValueError when range() gets 0 step.

parent de9b5369
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,12 @@ print(range(1, 4)[1:])
print(range(1, 4)[:-1])
print(range(7, -2, -4)[:])
# zero step
try:
range(1, 2, 0)
except ValueError:
print("ValueError")
# bad unary op
try:
-range(1)
......
......@@ -6,6 +6,13 @@ for x in range(*(1, 3)):
for x in range(1, *(6, 2)):
print(x)
# zero step
try:
for x in range(1, 2, 0):
pass
except ValueError:
print('ValueError')
# apply args using **
try:
for x in range(**{'end':1}):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment