summaryrefslogtreecommitdiff
path: root/tests/empty
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2013-12-13 12:02:54 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2013-12-17 10:17:44 +0100
commita4cb1400046f29f933b388ad6390f517e1f80c7a (patch)
tree29b3483e78c03d6742547ead0f8c5a1a75005352 /tests/empty
parentc5eac3a2f69acf12e794f6c9a3418c9051ce16ed (diff)
downloaddjango-a4cb1400046f29f933b388ad6390f517e1f80c7a.tar.gz
Added get_app_config() to look up app configs by label.
Refactored get_app() to rely on that method. get_app() starts by calling _populate(), which goes through INSTALLED_APPS and, for each app, imports the app module and attempts to import the models module. At this point, no further imports are necessary to return the models module for a given app. Therefore, the implementation of get_app() can be simplified and the safeguards for race conditions can be removed. Besides, the emptyOK parameter isn't used anywhere in Django. It was introduced in d6c95e93 but not actually used nor documented, and it has just been carried around since then. Since it's an obscure private API, it's acceptable to stop supporting it without a deprecation path. This branch aims at providing first-class support for applications without a models module eventually. For backwards-compatibility, get_app() still raises ImproperlyConfigured when an app isn't found, even though LookupError is technically more correct. I haven't gone as far as to preserve the exact error messages. I've adjusted a few tests instead.
Diffstat (limited to 'tests/empty')
-rw-r--r--tests/empty/tests.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/tests/empty/tests.py b/tests/empty/tests.py
index b8476fc73d..824c1f16e7 100644
--- a/tests/empty/tests.py
+++ b/tests/empty/tests.py
@@ -32,5 +32,5 @@ class NoModelTests(TestCase):
@override_settings(INSTALLED_APPS=("empty.no_models",))
def test_no_models(self):
with six.assertRaisesRegex(self, ImproperlyConfigured,
- 'App with label no_models is missing a models.py module.'):
+ "No app with label 'no_models'."):
app_cache.get_app('no_models')