Mocking imported modules in Python
- by Evgenyt
I'm trying to implement unit tests for function that uses imported external objects.
For example helpers.py is:
import os
import pylons
def some_func(arg):
...
var1 = os.path.exist(...)
var2 = os.path.getmtime(...)
var3 = pylons.request.environ['HTTP_HOST']
...
So when I'm creating unit test for it I do some mocking (minimock in…