は、私はあなたが投稿まさにテストし、それが私の作品:
<<< 12:18.25 Fri Feb 24 2012!~/testproject
<<< [email protected]!10019 env
>>> ./manage.py test testapp
Creating test database for alias 'default'...
Destroying old test database 'default'...
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
Destroying test database for alias 'default'...
<<< 12:18.27 Fri Feb 24 2012!~/testproject
<<< [email protected]!10020 env
>>> cat testapp/tests.py
from django.test import TestCase
from .settings import *
class SomeTestCase(TestCase):
def testSomething(self):
self.assertEqual(MY_SETTING_VAR, 'default')
<<< 12:18.30 Fri Feb 24 2012!~/testproject
<<< [email protected]!10021 env
>>> cat testapp/settings.py
from django.conf import settings
MY_SETTING_VAR = getattr(settings, 'MY_OVERRIDDEN_VAR', 'default')
あなたはあなたの実際のコードは、この作業コードと一致することを確認します。
アプリを示すか、少なくともテストを許可するダミープロジェクトをアプリに含めるとよいでしょう。たとえば:DJANGO_SETTINGS_MODULE
は、あなたのPythonの環境変数ではないので...あなたの問題を解決するためにあなたがあなたにそれを追加することができます
import os
os.environ['DJANGO_SETTINGS_MODULE'] = '<django_application_root>.settings'
として、あなたがそれを定義する必要があります
<<< 12:42.56 Fri Feb 24 2012!~/testproject/testapp
<<< [email protected]!10034 E:1 env
>>> pip install -e [email protected]:subsume/django-subscription.git#egg=sub
Obtaining sub from [email protected]:subsume/django-subscription.git#egg=sub
Cloning [email protected]:subsume/django-subscription.git to /home/jpic/env/src/sub
Running setup.py egg_info for package sub
Installing collected packages: sub
Running setup.py develop for sub
Creating /home/jpic/env/lib/python2.7/site-packages/django-subscription.egg-link (link to .)
Removing django-subscription 0.0 from easy-install.pth file
Adding django-subscription 0.1 to easy-install.pth file
Installed /home/jpic/env/src/sub
Successfully installed sub
Cleaning up...
<<< 12:43.08 Fri Feb 24 2012!~/testproject/testapp
<<< [email protected]!10035 env
<<< 12:43.11 Fri Feb 24 2012!~/testproject/testapp
<<< [email protected]!10035 env
>>> cd ../../env/src/sub
<<< 12:43.15 Fri Feb 24 2012!~/env/src/sub
<<< [email protected]!10036 G:master env
>>> ls
django_subscription.egg-info docs README setup.py subscription subscription_test_project
<<< 12:43.16 Fri Feb 24 2012!~/env/src/sub
<<< [email protected]!10037 G:master env
>>> cd subscription_test_project
<<< 12:43.20 Fri Feb 24 2012!~/env/src/sub/subscription_test_project
<<< [email protected]!10038 G:master env
>>> ./manage.py test subscription
Creating test database for alias 'default'...
........
----------------------------------------------------------------------
Ran 8 tests in 0.012s
OK
Destroying test database for alias 'default'...
私は愚かなコメントをしようとしていますが、他のパッケージがこれをどうやって行うのか調べましたか? – pkoch