运行测试时夹层导入错误
我最近将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(最近的最后一次调用):File“/Users/devarajn/.pythonbrew/venvs /Python-2.7.3/pari/lib/python2.7/site-packages/nose/loader.py“,第411行,在loadTestsFromName addr.filename,addr.module)文件”/Users/devarajn/.pythonbrew/venvs /Python-2.7.3/pari/lib/python2.7/site-packages/nose/importer.py“,第47行,在importFromPath中返回self.importFromDir(dir_path,fqname)文件”/Users/devarajn/.pythonbrew/文件“/用户/ devarajn文件”venvs / Python-2.7.3 / pari / lib / python2.7 / site-packages / nose / importer.py“,第94行,in importFromDir mod = load_module(part_fqname,fh, /repos/pari/pari/album/tests.py“,第8行,从pari.album.admin导入AlbumAdmin,AlbumImageInline File”/Users/devarajn/repos/pari/pari/album/admin.py“,第2行,in from mezzanine.core.admin import TabularDynamicInlineAdmin File“/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/l ib / python2.7 / site-packages / mezzanine / core / admin.py“,第4行,来自django.contrib.auth.admin import UserAdmin File”/Users/devarajn/.pythonbrew/venvs/Python-2.7.3 /pari/lib/python2.7/site-packages/django/contrib/auth/admin.py“,第182行,在admin.site.register(Group,GroupAdmin)文件中”/Users/devarajn/.pythonbrew/venvs/ (LazyAdminSite,self).register(* args,** kwargs)的第26行中的“Python-2.7.3 / pari / lib / python2.7 / site-packages / mezzanine / boot / lazy_admin.py” /Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/contrib/admin/sites.py“,第92行,注册admin_class.validate(model)文件“/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/contrib/admin/options.py”,第105行,验证validator = cls。在初始模型中,validator_class()文件“/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/contrib/admin/validation.py”,第20行.get_apps()文件“/Users/devarajn/.pyth onbrew / venvs / Python-2.7.3 / pari / lib / python2.7 / site-packages / django / db / models / loading.py“,第139行,在get_apps self._populate()File”/ 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”/ 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('%s.models '%app_name)文件“/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/utils/importlib.py”,第40行,在import_module import ( name)文件“/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/debug_toolbar/models.py”,第63行,在patch_root_urlconf()File“/ Users /devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/debug_toolbar/models.py“,第51行,位于patch_root_urlconf reverse('djdt:render_panel')文件”/ Users /devarajn/.pythonbrew/venvs/Python-2.7.3/pa ri / lib / python2.7 / site-packages / django / core / urlresolvers.py“,第480行,反向app_list = resolver.app_dict [ns]文件”/Users/devarajn/.pythonbrew/venvs/Python-2.7。 3 / pari / lib / python2.7 / site-packages / django / core / urlresolvers.py“,第310行,在app_dict self._populate()文件中”/Users/devarajn/.pythonbrew/venvs/Python-2.7.3 /pari/lib/python2.7/site-packages/django/core/urlresolvers.py“,第262行,在_populate模式中反转(self.url_patterns):File”/Users/devarajn/.pythonbrew/venvs/Python -2.7.3 / pari / lib / python2.7 / site-packages / django / core / urlresolvers.py“,第346行,在url_patterns patterns = getattr(self.urlconf_module,”urlpatterns“,self.urlconf_module)File”/用户/ 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 )文件“/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/utils/importlib.py”,第40行,in imp ort_module 导入 (名称)文件“/Users/devarajn/repos/pari/pari/urls.py”,第7行,在admin.autodiscover()文件中“/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/ pari / lib / python2.7 / site-packages / mezzanine / boot / init .py“,第77行,在autodiscover中django_autodiscover(* args,** kwargs)File”/Users/devarajn/.pythonbrew/venvs/Python-2.7 0.3 /帕里/ lib中/ python2.7 /站点包/ Django的/的contrib /管理/ 初始化的.py “第29行,在自动发现import_module( '%s.admin' %应用程序)文件”/用户/ devarajn /。 pythonbrew / venvs / Python-2.7.3 / pari / lib / python2.7 / site-packages / django / utils / importlib.py“,第40行,在import_module import (name)File中”/Users/devarajn/.pythonbrew/ venvs / Python-2.7.3 / pari / lib / python2.7 / site-packages / mezzanine / forms / admin.py“,第24行,来自mezzanine.pages.admin import PageAdmin File”/Users/devarajn/.pythonbrew /venvs/Python-2.7.3/pari/lib/python2.7/site-packages/mezzanine/pages/admin.py“,第12行,in from mezzanine.core.admin import DisplayableAdmin,DisplayableAdminForm ImportError:can not impo rt名称DisplayableAdmin
django-debug-toolbar模块导致了这个问题。
我从django-debug-toolbar v1.0.1回滚到v0.11。
这解决了错误。
链接地址: http://www.djcxy.com/p/40569.html上一篇: Mezzanine ImportError when running tests
下一篇: Cannot connect to Oracle database with Django on Ubuntu