简体   繁体   中英

How do I use PyMock and Nose with Django models?

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?

确实需要定义DJANGO_SETTINGS_MODULE才能运行core.py -为什么您不只是在bash会话中export DJANGO_SETTINGS_MODULE=whatever ,然后再开始鼻子?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM