Skip to content
Advertisement

Mock return value of a function for one case input, otherwise return original value

apps.my_module.py

JavaScript

I want to mock my_func in tests.py the mocked function return value for a is name is AA not name is a, but the return value for b and else must stay the same

I want to do this using unittest, how to do this?

Advertisement

Answer

The solution goes as the following:

in tests.py

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement