How do I use PyMock and Nose with Django models?

拥有回忆 提交于 2019-12-06 11:12:42

问题


I'm trying to do TDD with PyMock, but I keep getting error when I use Nose and execute core.py from command line:

"ERROR: Failure: ImportError (Settings cannot be imported, because environment variable DJA NGO_SETTINGS_MODULE is undefined.)"

If I remove "from cms.models import Entry" from the unit test module I created, everything works fine, but I need to mock functionality in django module cms.models.Entry that I created.

What am I doing wrong? Can this be done?


回答1:


You do need DJANGO_SETTINGS_MODULE defined in order to run core.py -- why don't you just export DJANGO_SETTINGS_MODULE=whatever in your bash session before starting nose?



来源:https://stackoverflow.com/questions/1484293/how-do-i-use-pymock-and-nose-with-django-models

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!