Ever had a child that asked, “Why?” to every answer you give. It could have started with your statement, “Children should do what their parents tell them to do.” If you try to answer each “Why?” thoroughly, you must psychoanalyze each answer until eventually you’re describing the meaning of the Universe. If that’s what is seems like when learning python’s “from unittest.mock patch, MagicMock”, you’ve come to the right place.
In this article I’m going to unravel the mystery of patch and MagicMock. If at first it seems you need the meaning of the Universe to get it, don’t worry, it’s not that hard. Once I got over this hurdle, writing unit_tests has become second nature. Read on and you can finally know “Why”.