diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-12-12 21:34:39 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-12-17 10:17:44 +0100 |
| commit | b55282b98bf7883490fcc586d501e1b36c7a1c9c (patch) | |
| tree | 43afde0c58dc9e0ecde78aecab4efb0433d30c2b /tests/app_loading/tests.py | |
| parent | 2c9e84af4a08096c47ebd3d54b463af1a3c7de77 (diff) | |
Moved list of models inside AppConfig instances.
This commit is a refactoring with no change of functionality, according
to the following invariants:
- An app_label that was in app_configs and app_models stays in
app_config and has its 'installed' attribute set to True.
- An app_label that was in app_models but not in app_configs is added to
app_configs and has its 'installed' attribute set to True.
As a consequence, all the code that iterated on app_configs is modified
to check for the 'installed' attribute. Code that iterated on app_models
is rewritten in terms of app_configs.
Many tests that stored and restored the state of the app cache were
updated.
In the long term, we should reconsider the usefulness of allowing
importing models from non-installed applications. This doesn't sound
particularly useful, can be a trap in some circumstances, and causes
significant complexity in sensitive areas of Django.
Diffstat (limited to 'tests/app_loading/tests.py')
| -rw-r--r-- | tests/app_loading/tests.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/tests/app_loading/tests.py b/tests/app_loading/tests.py index b24522fab6..6909564040 100644 --- a/tests/app_loading/tests.py +++ b/tests/app_loading/tests.py @@ -1,6 +1,5 @@ from __future__ import unicode_literals -import copy import os import sys from unittest import TestCase @@ -17,14 +16,15 @@ class EggLoadingTest(TestCase): self.old_path = sys.path[:] self.egg_dir = '%s/eggs' % os.path.dirname(upath(__file__)) - # This test adds dummy applications to the app cache. These - # need to be removed in order to prevent bad interactions - # with the flush operation in other tests. - self.old_app_models = copy.deepcopy(app_cache.app_models) + # The models need to be removed after the test in order to prevent bad + # interactions with the flush operation in other tests. + self._old_models = app_cache.app_configs['app_loading'].models.copy() def tearDown(self): + app_cache.app_configs['app_loading'].models = self._old_models + app_cache._get_models_cache = {} + sys.path = self.old_path - app_cache.app_models = self.old_app_models def test_egg1(self): """Models module can be loaded from an app in an egg""" |
