'Testing multiple method calls for mocked object Python
Yes, I have seen this question and this question.
However, I am curious if I have an ambiguous object with some method, so I can't really point to the direct object.
If I can do the below, without having to specify the mock_object
's module
mock_object = MagicMock()
mock_object.do_something.return_value = 5
I wonder why is something like this is requires me to patch the specific module for the object
mock_object = MagicMock()
mock_object.do_something.side_effect = [6,8]
Is not allowed? Is there a way to do this without specifying the specific object that the mock_object is tied to??
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|