Mezzanine ImportError when running tests

2019-09-17 14:02发布

I have recently upgraded the version of Django from 1.5.5 to 1.6.2 and Mezzanine to 3.0.9.

When I run

python manage.py test

All the tests run without problem.

But When I run project specific tests using

python manage.py test <project-name>

Then I get ImportError. I get that its something to do with Circular Imports.

Here is the stack trace. Please help.

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

ERROR: Failure: ImportError (cannot import name DisplayableAdmin) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/nose/loader.py", line 411, in loadTestsFromName addr.filename, addr.module) File "/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath return self.importFromDir(dir_path, fqname) File "/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir mod = load_module(part_fqname, fh, filename, desc) File "/Users/devarajn/repos/pari/pari/album/tests.py", line 8, in from pari.album.admin import AlbumAdmin, AlbumImageInline File "/Users/devarajn/repos/pari/pari/album/admin.py", line 2, in from mezzanine.core.admin import TabularDynamicInlineAdmin File "/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/mezzanine/core/admin.py", line 4, in from 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", line 182, in admin.site.register(Group, GroupAdmin) File "/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/mezzanine/boot/lazy_admin.py", line 26, in register super(LazyAdminSite, self).register(*args, **kwargs) File "/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 92, in register admin_class.validate(model) File "/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/contrib/admin/options.py", line 105, in validate validator = cls.validator_class() File "/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/contrib/admin/validation.py", line 20, in init models.get_apps() File "/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/db/models/loading.py", line 139, in get_apps self._populate() File "/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/db/models/loading.py", line 78, in _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", line 99, in load_app models = import_module('%s.models' % app_name) File "/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module import(name) File "/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/debug_toolbar/models.py", line 63, in patch_root_urlconf() File "/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/debug_toolbar/models.py", line 51, in patch_root_urlconf reverse('djdt:render_panel') File "/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/core/urlresolvers.py", line 480, in reverse app_list = resolver.app_dict[ns] File "/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/core/urlresolvers.py", line 310, in app_dict self._populate() File "/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/core/urlresolvers.py", line 262, in _populate for pattern in reversed(self.url_patterns): File "/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/core/urlresolvers.py", line 346, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/core/urlresolvers.py", line 341, in urlconf_module self._urlconf_module = import_module(self.urlconf_name) File "/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module import(name) File "/Users/devarajn/repos/pari/pari/urls.py", line 7, in admin.autodiscover() File "/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/mezzanine/boot/init.py", line 77, in autodiscover django_autodiscover(*args, **kwargs) File "/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/contrib/admin/init.py", line 29, in autodiscover import_module('%s.admin' % app) File "/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module import(name) File "/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/mezzanine/forms/admin.py", line 24, in from mezzanine.pages.admin import PageAdmin File "/Users/devarajn/.pythonbrew/venvs/Python-2.7.3/pari/lib/python2.7/site-packages/mezzanine/pages/admin.py", line 12, in from mezzanine.core.admin import DisplayableAdmin, DisplayableAdminForm ImportError: cannot import name DisplayableAdmin

1条回答
冷血范
2楼-- · 2019-09-17 14:20

django-debug-toolbar module was causing the issue.

I rolled back from django-debug-toolbar v1.0.1 to v0.11.

This fixed the error.

查看更多
登录 后发表回答