Irit Katriel <[email protected]> added the comment:
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.
----------
components: +Library (Lib)
nosy: +iritkatriel
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue42019>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com