Skip to content

Tag: python-mock

Python Mock Patch multiple methods in a class

Im trying to patch multiple methods in a class. Here is my simplified set up Hook.py is defined as HookTransfer.py defined as I want to mock the methods get_key and get_value in the Hook class. The following works i.e. prints New_Key and New_Value However this does not. It prints <MagicMock name=’Hoo…

Mocking async call in python 3.5

How do I mock async call from one native coroutine to other one using unittest.mock.patch? I currently have quite an awkward solution: Then This works but looks ugly. Is there more pythonic way to do this? Answer The solution was actually quite simple: I just needed to convert __call__ method of mock into cor…