0

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.

JerryCai
  • 1,663
  • 4
  • 21
  • 36
  • Wouldn't it be better to move the do lots of things, and only do them `if __name__ == '__main__'`? – doctorlove Nov 27 '13 at 15:04
  • @doctorlove I mean the do lots of things is in the method I need to test, I cannot modify the sourcecode but only test code. I want to mock this method before `import hander` from testsuite – JerryCai Nov 28 '13 at 01:55

0 Answers0