Return Value Not Set As Intended When Mocking A Method With @mock.patch.object
My test should with reason succeed as I'm giving a return value with mocker.return_value, which should give customers a value so the function call ends up in the else statement 'Cu
Solution 1:
It is not necessary to patch anything for this test. Since you're calling instance methods directly, you can simply pass a mock in as the self
parameter.
from datachecker import DataChecker
from unittest.mock import Mock
def test_find_customer_true(mocker):
mock_datachecker = Mock()
mock_datachecker.execute_db.return_value = [1]
assert DataChecker.find_customer(mock_datachecker, 1) == True
Post a Comment for "Return Value Not Set As Intended When Mocking A Method With @mock.patch.object"