Is there a way to mock "import .." in python unittest?

135 views Asked by At

I know in python by using mox, we can emulate the behaviour of a class propery or method. But when we new a instance or a target class, it does many things in its "import ..." class. My question is how to simulate the "import .." class behavour in mox? in client.py

from my.test import hander
......

in hander.py:

def _doLotOfThings():
#do a lot of things
_doLotOfThings()

Is there a way to inject hander.py's _doLotOfThings() before import hander that let it does nothing?

Thanks.

0

There are 0 answers