Message378654
I don't know whether this is intended behaviour of not, but it seems that MagicMock's __init__ is setting the magic methods, every time a mock instance is created. I was able to achieve what you tried to write with this class definition - it sets __len__ after super.__init__ has done what it needs to do.
class MagicMockChild(MagicMock):
def __init__(self):
super().__init__()
self.__len__ = lambda self : 9
This is not intended to be a satisfying answer, just to show what's going on. |
|
Date |
User |
Action |
Args |
2020-10-14 23:08:03 | iritkatriel | set | recipients:
+ iritkatriel, Indy |
2020-10-14 23:08:03 | iritkatriel | set | messageid: <1602716883.42.0.715399785028.issue42019@roundup.psfhosted.org> |
2020-10-14 23:08:03 | iritkatriel | link | issue42019 messages |
2020-10-14 23:08:03 | iritkatriel | create | |
|