I am writing several unittests for code written by someone else here in the office. Python is not the most powerful language. While I was successful with basic unit tests, the python mockery throws me into a loop.
What I need to do is override the ConfigObj call and insert my own config / fixture layout into any ConfigObj call.
settings.py
from configobj import ConfigObj config = ConfigObj('/etc/myapp/config')
utils.py
from settings import config """lots of stuff methods using various config values."""
What I would like to do, in my unittests for utils.py, insert yourself either for ANY call in ConfigObj, or in setup.py itself.
Many of the mocking libraries expect me to be a Mock for my classes, but in the case of this application it has no explicit classes.
Is it possible to do this, or are the python namespace restrictions too limited that I cannot interfere with which module I am importing myself?
Side note: 2.7 works, so I can not perform any tricks that I read about, starting with version 2.5.
lusis source share