By \"internal function\", I mean a function that is called from within the same module it is defined in.
I am using the mock library, specifically the patch decorators,
I'd like to add solution other than accepted one. You can also patch the module before it's been imported in any other modules and remove patch at the end of your test case.
#import some modules that don't use module you are going to patch
import unittest
from mock import patch
import json
import logging
...
patcher = patch('some.module.path.function', lambda x: x)
patcher.start()
import some.module.path
class ViewGetTests(unittest.TestCase):
@classmethod
def tearDownClass(cls):
patcher.stop()