Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Use of return value in Mock

def my_sum(a, b):
    return a + b

If i need to test the above function, I will write the test as

@patch('summodule.mysum')
def test_my_sum(mock_my_sum):
    mock_my_sum.return_value = 10
    assertEqual(mock_my_sum(6, 4), 10)

So what is the benefit if I, myself, is assigning a return value and then testing it in the next line??

If this is a wrong way to test the my_sum function, then what is the correct way?

Comments