Issue #2257
closedunit test failure: "AppRegistryNotReady: Apps aren't loaded yet."
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.
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.
----------------------------------------------------------------------
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
Updated by semyers over 7 years ago
How are you invoking the unittest runner? Is using manage.py insufficient?
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
Updated by mhrivnak over 7 years ago
- Status changed from POST to MODIFIED
Applied in changeset 8745e7ba330013adbe37d60cbca69701ea55a442.
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.
Updated by semyers over 7 years ago
- Status changed from 5 to CLOSED - CURRENTRELEASE
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