I'd like to replace a method in a class with mock:
from unittest.mock import patch
class A(object):
def method(self, string):
print(self, "method", string)
def method2(self, string):
print(self, "method2", string)
with patch.object(A, 'method', side_effect=method2):
a = A()
a.method("string")
a.method.assert_called_with("string")
...but I get insulted by the computer:
TypeError: method2() missing 1 required positional argument: 'string'