我有一个结构脚本,它试图为我编写的应用程序运行测试。
它已经使用 setup.py 安装,我可以导入它。
我正在按照我在这里找到的脚本。
我的问题是 django-admin 找不到我的应用程序:
回溯(最后一次调用):
文件“/usr/local/lib/python2.6/dist-packages/fabric/main.py”,第 542 行,在主要命令 [name](*args, **kwargs) 文件中“/usr/local/lib/python2.6/dist-packages/envconf/fabfile.py”,第 35 行,在测试 management.call_command('test', 'envconf') 文件“/usr/local/lib/python2 .6/dist-packages/django/core/management/ init .py”,第 166 行,在 call_command 返回 klass.execute(*args, **defaults) 文件“/usr/local/lib/python2.6/dist- packages/django/core/management/base.py”,第 220 行,在执行输出 = self.handle(*args, **options) 文件“/usr/local/lib/python2.6/dist-packages/django/ core/management/commands/test.py",第 37 行,在句柄故障 = test_runner。运行测试(测试标签)
文件“/usr/local/lib/python2.6/dist-packages/django/test/simple.py”,第 395 行,在 run_tests 套件 = self.build_suite(test_labels, extra_tests) 文件“/usr/local/lib/ python2.6/dist-packages/django/test/simple.py”,第 285 行,在 build_suite app = get_app(label) 文件“/usr/local/lib/python2.6/dist-packages/django/db/models /loading.py",第 140 行,在 get_app raise ImproperlyConfigured("App with label %s could not be found" % app_label) django.core.exceptions.ImproperlyConfigured: App with label envconf could not be found
这是我的代码: import functools import os
from fabric.api import local, cd, env
from fabric.contrib.project import rsync_project
from django.conf import settings
from django.core import management
NAME = os.path.basename(os.path.dirname(__file__))
ROOT = os.path.abspath(os.path.dirname(__file__))
os.environ['PYTHONPATH'] = os.pathsep.join([ROOT])
env.hosts = ['omer.me']
local = functools.partial(local, capture=False)
def test():
settings.configure(DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': '.',
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': '',
}
},
INSTALLED_APPS = ('envconf', ))
print os.environ
management.call_command('test', 'envconf')
有什么问题?