I'm trying to use Mock
to test the result returned from a function that retrieves a setting:
def apply_delta_to_date(original_date):
delta = MySettings.get_delta()
result_date = original_date + timedelta(delta)
return result_date
When testing the apply_delta_to_date
function, I'm trying to mock the call to MySettings.get_delta
to simulate that its returning a specific result:
class TestAppyDelta():
def setUp(self):
self.MySettings = Mock()
self.MySettings.get_delta = Mock(return_value=10)
def test_apply_delta(self):
result = apply_delta_to_date(today)
The problem is that I can't manage to "mock" the function call to MySettings.get_delta()
which is inside the function that I really want to test.
How could I mock the result returned by an inner function inside the function I'm testing?