2014-02-13 57 views
2

我正在學習使用django-nose,但我在設置時遇到了麻煩。Nosetests給出「錯誤配置」錯誤

./manage.py test工作得很好。但是nosetests沒有。

我添加了django_noseINSTALLED_APPS並設置了TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'。它仍然在提高ImproperlyConfigured

我試過Google搜索,但這不是一個常見問題,或者我一直在使用錯誤的查詢。那裏沒有運氣。

$ nosetests 

EE 
====================================================================== 
ERROR: Failure: 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.) 
---------------------------------------------------------------------- 
Traceback (most recent call last): 
    File "/home/ubuntu/virtualenv/python2.7/local/lib/python2.7/site-packages/nose/loader.py", line 413, in loadTestsFromName 
    addr.filename, addr.module) 
    File "/home/ubuntu/virtualenv/python2.7/local/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath 
    return self.importFromDir(dir_path, fqname) 
    File "/home/ubuntu/virtualenv/python2.7/local/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir 
    mod = load_module(part_fqname, fh, filename, desc) 
    File "/home/<path/to/app>/tests.py", line 1, in <module> 
    from django.test import TestCase 
    File "/home/ubuntu/virtualenv/python2.7/local/lib/python2.7/site-packages/django/test/__init__.py", line 5, in <module> 
    from django.test.client import Client, RequestFactory 
    File "/home/ubuntu/virtualenv/python2.7/local/lib/python2.7/site-packages/django/test/client.py", line 11, in <module> 
    from django.contrib.auth import authenticate, login, logout, get_user_model 
    File "/home/ubuntu/virtualenv/python2.7/local/lib/python2.7/site-packages/django/contrib/auth/__init__.py", line 6, in <module> 
    from django.middleware.csrf import rotate_token 
    File "/home/ubuntu/virtualenv/python2.7/local/lib/python2.7/site-packages/django/middleware/csrf.py", line 14, in <module> 
    from django.utils.cache import patch_vary_headers 
    File "/home/ubuntu/virtualenv/python2.7/local/lib/python2.7/site-packages/django/utils/cache.py", line 26, in <module> 
    from django.core.cache import get_cache 
    File "/home/ubuntu/virtualenv/python2.7/local/lib/python2.7/site-packages/django/core/cache/__init__.py", line 69, in <module> 
    if DEFAULT_CACHE_ALIAS not in settings.CACHES: 
    File "/home/ubuntu/virtualenv/python2.7/local/lib/python2.7/site-packages/django/conf/__init__.py", line 54, in __getattr__ 
    self._setup(name) 
    File "/home/ubuntu/virtualenv/python2.7/local/lib/python2.7/site-packages/django/conf/__init__.py", line 47, in _setup 
    % (desc, ENVIRONMENT_VARIABLE)) 
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. 
+0

您是否嘗試過運行'python manage.py test'? – dirn

+0

是 - 「'./manage.py test'工作得很好。」 –

+0

有趣的是,'python manage.py test'的第一行輸出是'nosetests --verbosity = 1'。 –

回答

2

@dirn回答這個問題,但離開它作爲一個評論..

我不應該直接運行nosetests,但應該使用python manage.py test和有蟒蛇調用鼻子對我來說不是。