Question

When running nosetests, django-nose runner doesn't supply --with-django option to nosetests, so my nose + Twill tests fail when trying to access URLs:

./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)

When I supply --with-django manually or set NOSE_WITH_DJANGO=1 enviromental variable, my tests run successfully, but then I receive following exception:

$ ./manage.py test --with-django
...
Ran 2 tests in 0.199s

OK
...
AttributeError: type object 'Template' has no attribute 'original_render'

nosetests --with-django runs tests successfully

Was it helpful?

Solution

Turns out the problem was that I used tddspry with django-nose and they both has their own similar setup/teardown plugin, so I subclassed django-nose TestRunner and removed that plugin from defaults.

To solve this problem, install latest tddspry from official git repository, latest stable django-nose from PyPI and add tddspry TestSuiteRunner to Django settings as follows:

TEST_RUNNER = 'tddspry.django.runner.TestSuiteRunner'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top