I\'ve been using the python mock module for my test-cases. Frequently I decorate my test cases with the @patch(\'my_method\') decorator. Then in the body of the
If you want to use patch just for its call-logging functionality, without mocking out the original function's behavior, then specify the original function as the side_effect of the mock:
@patch('my_function', side_effect=my_function)
...
The side_effect name is misleading. If a mock has a side_effect function, calling the mock will call the side_effect and return or raise whatever the side_effect returns or raises. Using the original function as side_effect means we get the original function's behavior. (side_effect can be a few other kinds of thing besides functions, but we don't need that functionality here.)