Commit d690c2e1 authored by Paul Sokolovsky's avatar Paul Sokolovsky Committed by Damien George

tests/basics/special_methods: Add testcases for __int__.

parent b1d08726
......@@ -93,6 +93,9 @@ class Cud():
print("__isub__ called")
return self
def __int__(self):
return 42
cud1 = Cud()
cud2 = Cud()
......@@ -104,5 +107,16 @@ cud1 >= cud2
cud1 > cud2
cud1 + cud2
cud1 - cud2
print(int(cud1))
class BadInt:
def __int__(self):
print("__int__ called")
return None
try:
int(BadInt())
except TypeError:
print("TypeError")
# more in special_methods2.py
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment