1

Closed

Test explorer can't run django tests

description

DJANGO_SETTINGS_MODULE is not defined error:
Test Name:  test_about
Test Outcome:   Failed
Result StandardError:   
Traceback (most recent call last):
  File "C:\USERS\HUVALO\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\12.0EXP\EXTENSIONS\MICROSOFT\PYTHON TOOLS FOR VISUAL STUDIO\2.1\visualstudio_py_testlauncher.py", line 39, in <module>
    __import__(opts.module)
  File "c:\users\huvalo\documents\visual studio 2013\Projects\DjangoWebProject13\DjangoWebProject13\app\tests.py", line 6, in <module>
    from django.test import TestCase
  File "C:\Python27\lib\site-packages\django\test\__init__.py", line 5, in <module>
    from django.test.client import Client, RequestFactory
  File "C:\Python27\lib\site-packages\django\test\client.py", line 11, in <module>
    from django.contrib.auth import authenticate, login, logout, get_user_model
  File "C:\Python27\lib\site-packages\django\contrib\auth\__init__.py", line 6, in <module>
    from django.middleware.csrf import rotate_token
  File "C:\Python27\lib\site-packages\django\middleware\csrf.py", line 14, in <module>
    from django.utils.cache import patch_vary_headers
  File "C:\Python27\lib\site-packages\django\utils\cache.py", line 26, in <module>
    from django.core.cache import get_cache
  File "C:\Python27\lib\site-packages\django\core\cache\__init__.py", line 69, in <module>
    if DEFAULT_CACHE_ALIAS not in settings.CACHES:
  File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 54, in __getattr__
    self._setup(name)
  File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 47, in _setup
    % (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting CACHES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
Closed Jun 25 at 5:59 PM by Zooba

comments

Zooba wrote Jun 24 at 11:21 PM

Can you post your entire project? Using TestCase from django should be sufficient to make this work - it's worked every other time this issue has been reported.

huguesv wrote Jun 25 at 5:18 PM

Using Beta 2 build, you can repro by creating Django Web Project, Django Sync DB, then run test_basic_addition from Test Explorer. I'm using Python 2.7 and Django 1.6.2.

In post Beta 2 the tests are slightly different, but same result.