You would write:
class Class1Test(TestCase):
@mock.patch('mymodule.external_function')
def test_method1(self, mock_external_function):
pass
Looking at mymodule
the function external_function
is directly imported. Hence you need to mock mymodule.external_function
as that's the function that will be called when method1
is executed.