问题描述
我正在尝试使用PyMock进行TDD,但是当我使用Nose并在命令行中执行core.py时,我会收到错误:错误:失败:ImportError(无法导入设置,因为环境变量DJA
NGO_SETTINGS_MODULE未定义。)
如果从cms.models import Entry中删除单元测试模块我创建,一切正常,但我需要模拟功能在django模块cms.models.Entry我创建。
我做错了什么?这可以做吗?
你做需要 DJANGO_SETTINGS_MODULE
为了运行 core.py
- 为什么不只是 export DJANGO_SETTINGS_MODULE = whatever
在你开始鼻子之前的bash会话中?
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 DJANGO_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?
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?
这篇关于如何在Django模型中使用PyMock和Nose?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!