django-nose testrunner不使用--with-django选项

时间:2010-08-20 13:36:59

标签: django unit-testing nose twill

运行nosetests时,django-nose runner不会向--with-django提供nosetests选项,因此在尝试访问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成功运行测试

1 个答案:

答案 0 :(得分:0)

原来问题是我使用了tddspry django-nose并且他们都有自己类似的setup / teardown插件,所以我将django-nose TestRunner子类化并从默认设置中删除了该插件。

要解决此问题,请从官方git repository,最新稳定tddspry from PyPI安装最新django-nose,并将dddpry TestSuiteRunner添加到Django设置,如下所示:

TEST_RUNNER = 'tddspry.django.runner.TestSuiteRunner'