Using mock's capabilities within Python 3, I want to wrap a function and have it perform all of its normal functionality, and I simply want to mock its return value. In other words, I don't want to mock the entire function, just its return value, and I don't know how to make that happen.
def func():
# do something
# do something else
# do lots of other things
retval = 123
return retval
with mock.patch('func') as mocked:
mocked.return_value = 456
# And now, I want to run the function so that when
# it's called, "do something", "do something else",
# and "do lots of other things" still get performed,
# but that 456 gets returned instead of 123.