There are plenty of examples that shows how to assert a method has been called using Mock, eg. assert_called_with()
, but all of them involve replacing the method with Mock instance.
What I want is a little bit different, I want the function to be executed normally without its body replaced, but still want to assert if the function has been called.
eg.
def dosomething(...)
# creates records that I will test later on.
....
def execute():
....
dosomething()
in my tests
def test_a(...):
with patch(dosomething...) as mocked:
execute()
mocked.assert_called_with()
I know I can test against the records that dosomething()
creates instead. Yes I agree, but I just want to find out if it's possible to do per as my question.