运行测试时的Mezzanine ImportError

时间:2014-03-28 09:45:17

标签: python django python-2.7 content-management-system mezzanine

我最近将Django的版本从1.5.5升级到1.6.2,将Mezzanine升级到3.0.9。

当我跑步时

python manage.py test

所有测试都没有问题。

但是当我使用

运行项目特定测试时
python manage.py test <project-name>

然后我得到ImportError。我认为它与Circular Imports有关。

这是堆栈跟踪。请帮忙。

  

=============================================== =======================

     
    

错误:失败:ImportError(无法导入名称DisplayableAdmin)      -------------------------------------------------- -------------------- Traceback(最近一次调用最后一次):文件     &#34; /Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/nose/loader.py" ;,     第410行,在loadTestsFromName中         addr.filename,addr.module)File&#34; /Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/nose/importer.py",     第47行,在importFromPath中         return self.importFromDir(dir_path,fqname)File&#34; /Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/nose/importer.py" ,     第94行,在importFromDir中         mod = load_module(part_fqname,fh,filename,desc)File&#34; /Users/devarajn/repos/pari/pari/album/tests.py" ;,第8行,in         来自pari.album.admin导入AlbumAdmin,AlbumImageInline文件&#34; /Users/devarajn/repos/pari/pari/album/admin.py" ;,第2行,in         来自mezzanine.core.admin导入TabularDynamicInlineAdmin文件     &#34; /Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/mezzanine/core/admin.py" ;,     第4行,在         来自django.contrib.auth.admin导入UserAdmin文件&#34; /Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/contrib/auth/admin .py&#34;,第182行,in         admin.site.register(Group,GroupAdmin)File&#34; /Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/mezzanine/boot/lazy_admin.py& #34;,第26行,在寄存器中         super(LazyAdminSite,self).register(* args,** kwargs)File&#34; /Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django /contrib/admin/sites.py" ;,第92行,在寄存器中         admin_class.validate(model)File&#34; /Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/contrib/admin/options.py" ;,第105行,在验证中         validator = cls.validator_class()File&#34; /Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/contrib/admin/validation.py&# 34 ;,     第20行,在 init 中         models.get_apps()File&#34; /Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/db/models/loading.py" ,     第139行,在get_apps中         self._populate()File&#34; /Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/db/models/loading.py" ,     第78行,在_populate中         self.load_app(app_name)File&#34; /Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/db/models/loading.py" ;,     第99行,在load_app中         models = import_module(&#39;%s.models&#39;%app_name)文件&#34; /Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages /django/utils/importlib.py" ;,     第40行,在import_module中         导入(名称)文件&#34; /Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/debug_toolbar/models.py&# 34 ;,     第63行,在         patch_root_urlconf()File&#34; /Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/debug_toolbar/models.py",     第51行,在patch_root_urlconf中         反向(&#39; djdt:render_panel&#39;)文件&#34; /Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/core/ urlresolvers.py&#34 ;,     第480行,相反         app_list = resolver.app_dict [ns] File&#34; /Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/core/urlresolvers.py" ;,     第310行,在app_dict中         self._populate()File&#34; /Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/core/urlresolvers.py",     第262行,在_populate中         对于反转模式(self.url_patterns):File&#34; /Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/core/urlresolvers.py& #34 ;,     第346行,在url_patterns中         patterns = getattr(self.urlconf_module,&#34; urlpatterns&#34;,self.urlconf_module)文件     &#34; /Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/core/urlresolvers.py" ;,     第341行,在urlconf_module中         self._urlconf_module = import_module(self.urlconf_name)File&#34; /Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/utils/importlib.py& #34 ;,     第40行,在import_module中         导入(名称)文件&#34; /Users/devarajn/repos/pari/pari/urls.py",第7行,在         admin.autodiscover()File&#34; /Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/mezzanine/boot/ init 的.py&#34 ;,     第77行,在自动发现中         django_autodiscover(* args,** kwargs)File&#34; /Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/contrib/admin/ 初始化的.py&#34 ;,     第29行,在自动发现中         import_module(&#39;%s.admin&#39;%app)文件&#34; /Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django /utils/importlib.py" ;,     第40行,在import_module中         导入(名称)文件&#34; /Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/mezzanine/forms/admin。 PY&#34 ;,     第24行,在         来自mezzanine.pages.admin import PageAdmin File&#34; /Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/mezzanine/pages/admin.py" ;,     第12行,在         来自mezzanine.core.admin导入DisplayableAdmin,DisplayableAdminForm ImportError:无法导入名称     DisplayableAdmin

  

1 个答案:

答案 0 :(得分:1)

django-debug-toolbar模块导致了这个问题。

我从django-debug-toolbar v1.0.1回滚到v0.11。

这解决了错误。