tests/basics/special_methods: Add testcases for __int__.

This commit is contained in:
Paul Sokolovsky 2018-08-29 18:27:20 +03:00 committed by Damien George
parent b1d08726ee
commit d690c2e148

View File

@ -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