运行nosetests 时,django-nose runner 不提供--with-django
选项 to nosetests
,因此我的nose + Twill 测试在尝试访问 URL 时失败:
./manage.py test
...
raise BrowserStateError("cannot go to '%s'" % (url,))
BrowserStateError: cannot go to 'http://127.0.0.1:8088/admin/'
----------------------------------------------------------------------
Ran 2 tests in 0.166s
FAILED (errors=1)
当我--with-django
手动提供或设置NOSE_WITH_DJANGO=1
环境变量时,我的测试成功运行,但随后我收到以下异常:
$ ./manage.py test --with-django
...
Ran 2 tests in 0.199s
OK
...
AttributeError: type object 'Template' has no attribute 'original_render'
nosetests --with-django
成功运行测试