circuitpython/tests/basics/class_getattr.py
Damien George a07e56cbd8 tests/basics/class_getattr: Remove invalid test for __getattribute__.
Part of this test was trying to test some functionality of __getattribute__
but this method name was misspelt so it wasn't doing anything useful.
Fixing the typo in this name makes the test fail because MicroPython
doesn't support user defined __getattribute__ methods.  So this part of the
test is removed.  The remaining tests are modified slightly to make it
clearer what they are testing.
2018-10-18 12:28:09 +11:00

15 lines
433 B
Python

# test that __getattr__ and instance members don't override builtins
class C:
def __init__(self):
self.__add__ = lambda: print('member __add__')
def __add__(self, x):
print('__add__')
def __getattr__(self, attr):
print('__getattr__', attr)
return None
c = C()
c.add # should call __getattr__
c.__add__() # should load __add__ instance directly
c + 1 # should call __add__ method directly