How can I use mock.patch on a function, so I have an access to methods .assert_called etc. and simultaneously I can still preserve original functionality of the functions?
Here is example code:
from unittest import mock
def foo(arg):
print(arg)
def tested():
foo('hi')
@mock.patch('__main__.foo')
def test(foo):
tested()
foo.assert_called_once()
test()
I want it to test if the foo function was called just once but I still need it to print hi.