Project

Profile

Help

Issue #2257

closed

unit test failure: "AppRegistryNotReady: Apps aren't loaded yet."

Added by mhrivnak over 7 years ago. Updated almost 5 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
High
Assignee:
Sprint/Milestone:
-
Start date:
Due date:
Estimated time:
Severity:
2. Medium
Version:
Master
Platform Release:
2.10.1
OS:
Fedora 24
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Pulp 2
Sprint:
Sprint 8
Quarter:

Description

It appears that django 1.9 (which is in F24) changed some behavior and now requires that django.setup() gets called before using the Template object in a stand-alone use case.

https://docs.djangoproject.com/en/1.9/topics/settings/#calling-django-setup-is-required-for-standalone-django-usage

It's documented as a requirement even for 1.8, but that hasn't prevented our tests from working until 1.9.

These are the test failures:

======================================================================
ERROR: test_render_filelists (test.unit.plugins.db.test_models.TestRpmBaseRender)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/vagrant/devel/pulp_rpm/plugins/test/unit/plugins/db/test_models.py", line 1124, in test_render_filelists
    ret = self.unit.render_filelists('sha1')
  File "/home/vagrant/devel/pulp_rpm/plugins/pulp_rpm/plugins/db/models.py", line 802, in render_filelists
    return self._render(metadata, context)
  File "/home/vagrant/devel/pulp_rpm/plugins/pulp_rpm/plugins/db/models.py", line 817, in _render
    t = Template(template)
  File "/usr/lib/python2.7/site-packages/django/template/base.py", line 182, in __init__
    engine = Engine.get_default()
  File "/usr/lib/python2.7/site-packages/django/utils/lru_cache.py", line 124, in wrapper
    result = user_function(*args, **kwds)
  File "/usr/lib/python2.7/site-packages/django/template/engine.py", line 88, in get_default
    django_engines = [engine for engine in engines.all()
  File "/usr/lib/python2.7/site-packages/django/template/utils.py", line 110, in all
    return [self[alias] for alias in self]
  File "/usr/lib/python2.7/site-packages/django/template/utils.py", line 101, in __getitem__
    engine = engine_cls(params)
  File "/usr/lib/python2.7/site-packages/django/template/backends/django.py", line 31, in __init__
    options['libraries'] = self.get_templatetag_libraries(libraries)
  File "/usr/lib/python2.7/site-packages/django/template/backends/django.py", line 49, in get_templatetag_libraries
    libraries = get_installed_libraries()
  File "/usr/lib/python2.7/site-packages/django/template/backends/django.py", line 132, in get_installed_libraries
    for app_config in apps.get_app_configs())
  File "/usr/lib/python2.7/site-packages/django/apps/registry.py", line 137, in get_app_configs
    self.check_apps_ready()
  File "/usr/lib/python2.7/site-packages/django/apps/registry.py", line 124, in check_apps_ready
    raise AppRegistryNotReady("Apps aren't loaded yet.")
AppRegistryNotReady: Apps aren't loaded yet.

======================================================================
ERROR: test_render_other (test.unit.plugins.db.test_models.TestRpmBaseRender)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/vagrant/devel/pulp_rpm/plugins/test/unit/plugins/db/test_models.py", line 1129, in test_render_other
    ret = self.unit.render_other('sha1')
  File "/home/vagrant/devel/pulp_rpm/plugins/pulp_rpm/plugins/db/models.py", line 788, in render_other
    return self._render(metadata, context)
  File "/home/vagrant/devel/pulp_rpm/plugins/pulp_rpm/plugins/db/models.py", line 817, in _render
    t = Template(template)
  File "/usr/lib/python2.7/site-packages/django/template/base.py", line 182, in __init__
    engine = Engine.get_default()
  File "/usr/lib/python2.7/site-packages/django/utils/lru_cache.py", line 124, in wrapper
    result = user_function(*args, **kwds)
  File "/usr/lib/python2.7/site-packages/django/template/engine.py", line 88, in get_default
    django_engines = [engine for engine in engines.all()
  File "/usr/lib/python2.7/site-packages/django/template/utils.py", line 110, in all
    return [self[alias] for alias in self]
  File "/usr/lib/python2.7/site-packages/django/template/utils.py", line 101, in __getitem__
    engine = engine_cls(params)
  File "/usr/lib/python2.7/site-packages/django/template/backends/django.py", line 31, in __init__
    options['libraries'] = self.get_templatetag_libraries(libraries)
  File "/usr/lib/python2.7/site-packages/django/template/backends/django.py", line 49, in get_templatetag_libraries
    libraries = get_installed_libraries()
  File "/usr/lib/python2.7/site-packages/django/template/backends/django.py", line 132, in get_installed_libraries
    for app_config in apps.get_app_configs())
  File "/usr/lib/python2.7/site-packages/django/apps/registry.py", line 137, in get_app_configs
    self.check_apps_ready()
  File "/usr/lib/python2.7/site-packages/django/apps/registry.py", line 124, in check_apps_ready
    raise AppRegistryNotReady("Apps aren't loaded yet.")
AppRegistryNotReady: Apps aren't loaded yet.

======================================================================
ERROR: test_render_primary (test.unit.plugins.db.test_models.TestRpmBaseRender)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/vagrant/devel/pulp_rpm/plugins/test/unit/plugins/db/test_models.py", line 1134, in test_render_primary
    ret = self.unit.render_primary('sha1')
  File "/home/vagrant/devel/pulp_rpm/plugins/pulp_rpm/plugins/db/models.py", line 772, in render_primary
    return self._render(metadata, context)
  File "/home/vagrant/devel/pulp_rpm/plugins/pulp_rpm/plugins/db/models.py", line 817, in _render
    t = Template(template)
  File "/usr/lib/python2.7/site-packages/django/template/base.py", line 182, in __init__
    engine = Engine.get_default()
  File "/usr/lib/python2.7/site-packages/django/utils/lru_cache.py", line 124, in wrapper
    result = user_function(*args, **kwds)
  File "/usr/lib/python2.7/site-packages/django/template/engine.py", line 88, in get_default
    django_engines = [engine for engine in engines.all()
  File "/usr/lib/python2.7/site-packages/django/template/utils.py", line 110, in all
    return [self[alias] for alias in self]
  File "/usr/lib/python2.7/site-packages/django/template/utils.py", line 101, in __getitem__
    engine = engine_cls(params)
  File "/usr/lib/python2.7/site-packages/django/template/backends/django.py", line 31, in __init__
    options['libraries'] = self.get_templatetag_libraries(libraries)
  File "/usr/lib/python2.7/site-packages/django/template/backends/django.py", line 49, in get_templatetag_libraries
    libraries = get_installed_libraries()
  File "/usr/lib/python2.7/site-packages/django/template/backends/django.py", line 132, in get_installed_libraries
    for app_config in apps.get_app_configs())
  File "/usr/lib/python2.7/site-packages/django/apps/registry.py", line 137, in get_app_configs
    self.check_apps_ready()
  File "/usr/lib/python2.7/site-packages/django/apps/registry.py", line 124, in check_apps_ready
    raise AppRegistryNotReady("Apps aren't loaded yet.")
AppRegistryNotReady: Apps aren't loaded yet.

----------------------------------------------------------------------
Actions #1

Updated by mhrivnak over 7 years ago

  • OS set to Fedora 24
Actions #2

Updated by mhrivnak over 7 years ago

  • Status changed from NEW to POST
  • Assignee set to mhrivnak
  • Priority changed from Normal to High
  • Triaged changed from No to Yes
Actions #3

Updated by mhrivnak over 7 years ago

  • Sprint/Milestone set to 26
Actions #4

Updated by semyers over 7 years ago

How are you invoking the unittest runner? Is using manage.py insufficient?

Actions #5

Updated by semyers over 7 years ago

This bug is marked triaged, but does not appear in the triage logs. When/where was it triaged?

Added by mhrivnak over 7 years ago

Revision 8745e7ba | View on GitHub

Adds a required django.setup() call to unit tests.

Some unit tests failed under django 1.9 without this setup call.

https://pulp.plan.io/issues/2257 fixes #2257

Actions #6

Updated by mhrivnak over 7 years ago

  • Status changed from POST to MODIFIED
Actions #7

Updated by mhrivnak over 7 years ago

This was ad-hoc triaged outside the normally scheduled meetings, since it was slowing down development.

To echo the answer to the other question, which is also on the PR, pulp 2 doesn't have manage.py, so I was invoking with the run-tests.py script.

Actions #8

Updated by semyers over 7 years ago

  • Platform Release set to 2.10.1
Actions #9

Updated by semyers over 7 years ago

  • Status changed from MODIFIED to 5
Actions #10

Updated by semyers over 7 years ago

  • Status changed from 5 to CLOSED - CURRENTRELEASE
Actions #11

Updated by bmbouter about 6 years ago

  • Sprint set to Sprint 8
Actions #12

Updated by bmbouter about 6 years ago

  • Sprint/Milestone deleted (26)
Actions #13

Updated by bmbouter almost 5 years ago

  • Tags Pulp 2 added

Also available in: Atom PDF