There are two problems in the code:
1) The class method is not declared correctly
class class_c():
@classmethod
def function_c(cls):
return 123
2) @patch is used incorrectly. You need to change it to
def mock_method(cls):
return 7890
@patch("modb.class_b.function_c", new=classmethod(mock_method))
def test_method():
result = function_a()
print result
source
share