Logo
Explore Help
Register Sign In
fengqi/lv_micropython
1
0
Fork 0
You've already forked lv_micropython
Code Issues Pull Requests 1 Actions Packages Projects Releases Wiki Activity
lv_micropython/tests/basics/class_reverse_op.py

19 lines
329 B
Python
Raw Normal View History

tests/class_reverse_op: Test for reverse arith ops special methods. This test should be run only if support for reverse ops is enabled, so the corresponding feature_check is added to run-tests.
2017-09-10 17:05:31 +03:00
class A:
def __init__(self, v):
self.v = v
def __add__(self, o):
if isinstance(o, A):
return A(self.v + o.v)
return A(self.v + o)
def __radd__(self, o):
return A(self.v + o)
def __repr__(self):
tests/basics: Use str.format instead of % for formatting messages. Only use % formatting when testing % itself, because only str.format is guaranteed to be available on any port.
2019-10-18 19:18:06 +11:00
return "A({})".format(self.v)
tests/class_reverse_op: Test for reverse arith ops special methods. This test should be run only if support for reverse ops is enabled, so the corresponding feature_check is added to run-tests.
2017-09-10 17:05:31 +03:00
print(A(3) + 1)
print(2 + A(5))
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.23.8 Page: 117ms Template: 1ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API