Last Updated: February 25, 2016
·
396
· rsludge

Stub function from module

Lets you want to test module(module1) which imports function from another module:

from module2 import some_function
some_function()

To stub this function in test you should do something like this:

import module1
module1.module2.some_function = fake_function