We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 064d671 commit caa5382Copy full SHA for caa5382
tests/test_builtin_casters.py
@@ -268,6 +268,13 @@ class IndexedThought(object):
268
def __index__(self):
269
return 42
270
271
+ class TypeErrorThought(object):
272
+ def __index__(self):
273
+ raise TypeError
274
+
275
+ def __int__(self):
276
+ return 42
277
278
class RaisingThought(object):
279
280
raise ValueError
@@ -295,6 +302,8 @@ def cant_convert(v):
295
302
# "backports" this behavior.
296
303
assert convert(IndexedThought()) == 42
297
304
assert noconvert(IndexedThought()) == 42
305
+ assert convert(TypeErrorThought()) == 42
306
+ require_implicit(TypeErrorThought())
298
307
cant_convert(RaisingThought()) # no fall-back to `__int__`if `__index__` raises
299
308
300
309
0 commit comments