In the mock, I want a certain function to return a new value in the test. This is how i did it.
Class MyClass:
my_var = None
def foo(self, var1):
return somevalue
def bar(self):
my_var = foo(1)
Class TestClass(unittest.TestCase):
myClass = MyClass()
def _side_effect_foo(var1):
if condition:
return new_value
@patch("MyClass", "foo", side_effect='_side_effect_foo')
def test_foo(self):
self.myClass.bar()
This gives me a error:
Can't pass kwargs to a mock we aren't creating.
Am I using the correct format of side_effect?
Thanks for any help!