Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add tests for __index__
  • Loading branch information
HyeockJinKim committed Sep 29, 2019
commit 9cc7591414d238ba37754e3f28fe2b154d61724f
20 changes: 20 additions & 0 deletions py/tests/range.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,24 @@ def __index__(self):
assert a[b:10] == a[1:10]
assert a[10:b:-1] == a[10:1:-1]

class NonIntegerIndex:
def __index__(self):
return 1.1

a = range(10)
b = NonIntegerIndex()
try:
a[b]
except TypeError:
pass
else:
assert False, "TypeError not raised"

try:
a[b:10]
except TypeError:
pass
else:
assert False, "TypeError not raised"

doc="finished"