What is difference between python mock and magic mock, because I could see
>>> dir(Mock()) == dir(MagicMock())
True
when to use mock obj & when to use MagicMock obj??
MagicMock is a subclass of Mock with default implementations of many magic methods. You can use MagicMock without having to configure the magic methods yourself.
I suppose the code above is to affect most of magic methods to your mock automatically
check this guide it may help you Magic Methods
and official doc https://docs.python.org/2/reference/datamodel.html#special-method-names
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With