diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2018-08-29 18:27:20 +0300 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2018-12-07 17:28:04 +1100 |
commit | d690c2e148796cd1019b9e4c41bc9e196c7b36b7 (patch) | |
tree | 8858ce287f84e55ac419cfb82d83236a1f583608 /tests/basics/special_methods.py | |
parent | b1d08726eeeadf0b91358cc8c46e156695b6a9c0 (diff) | |
download | micropython-d690c2e148796cd1019b9e4c41bc9e196c7b36b7.tar.gz micropython-d690c2e148796cd1019b9e4c41bc9e196c7b36b7.zip |
tests/basics/special_methods: Add testcases for __int__.
Diffstat (limited to 'tests/basics/special_methods.py')
-rw-r--r-- | tests/basics/special_methods.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/basics/special_methods.py b/tests/basics/special_methods.py index 9f57247c12..b56bc1c9c4 100644 --- a/tests/basics/special_methods.py +++ b/tests/basics/special_methods.py @@ -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 |