我想測試一個帶有自己設置模塊的小型可重用應用程序。全局(項目)設置可在應用程序設置中訪問,以支持變量的覆蓋,例如,使用Django testrunner測試可重複使用的Django應用程序
# in <my_app>/settings.py
from django.conf import settings
MY_SETTING_VAR = getattr(settings, 'MY_OVERRIDDEN_VAR', False)
當我運行manage.py測試MYAPP我得到的測試如下:
ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.
什麼是運行在這種情況下測試的正確方法?
我即將做出一個愚蠢的評論,但是,你看看其他軟件包如何做到這一點? – pkoch 2012-02-25 05:38:35