diff options
author | Tim Graham <timograham@gmail.com> | 2013-08-05 13:34:35 -0400 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2013-08-05 13:34:35 -0400 |
commit | 04489c7dbf8f69de84ca272a0a1710e7b6067e9d (patch) | |
tree | 161a1ef94b70e5922c55aed5811b2e65ad3287e9 /tests/app_loading | |
parent | 75c87e2d38b181163a61ea99f2a17273274a3a2b (diff) | |
download | django-04489c7dbf8f69de84ca272a0a1710e7b6067e9d.tar.gz |
Fixed #17667 -- Prevented app loading from skipping nonexistent apps after the first try
Thanks ea2100@ for the report and akaariai for the patch.
Diffstat (limited to 'tests/app_loading')
-rw-r--r-- | tests/app_loading/tests.py | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/tests/app_loading/tests.py b/tests/app_loading/tests.py index bba2b234a2..dc25899646 100644 --- a/tests/app_loading/tests.py +++ b/tests/app_loading/tests.py @@ -7,7 +7,8 @@ import time from unittest import TestCase from django.conf import Settings -from django.db.models.loading import cache, load_app, get_model, get_models +from django.db.models.loading import cache, load_app, get_model, get_models, AppCache +from django.test.utils import override_settings from django.utils._os import upath @@ -61,12 +62,33 @@ class EggLoadingTest(TestCase): egg_name = '%s/brokenapp.egg' % self.egg_dir sys.path.append(egg_name) self.assertRaises(ImportError, load_app, 'broken_app') + raised = None try: load_app('broken_app') except ImportError as e: - # Make sure the message is indicating the actual - # problem in the broken app. - self.assertTrue("modelz" in e.args[0]) + raised = e + + # Make sure the message is indicating the actual + # problem in the broken app. + self.assertTrue(raised is not None) + self.assertTrue("modelz" in raised.args[0]) + + def test_missing_app(self): + """ + Test that repeated app loading doesn't succeed in case there is an + error. Refs #17667. + """ + # AppCache is a Borg, so we can instantiate one and change its + # loaded to False to force the following code to actually try to + # populate the cache. + a = AppCache() + a.loaded = False + try: + with override_settings(INSTALLED_APPS=('notexists',)): + self.assertRaises(ImportError, get_model, 'notexists', 'nomodel', seed_cache=True) + self.assertRaises(ImportError, get_model, 'notexists', 'nomodel', seed_cache=True) + finally: + a.loaded = True class GetModelsTest(TestCase): |