summaryrefslogtreecommitdiff
path: root/tests/admin_scripts
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/admin_scripts
parentc5eac3a2f69acf12e794f6c9a3418c9051ce16ed (diff)
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/admin_scripts')
-rw-r--r--tests/admin_scripts/tests.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py
index 73a91b6e7b..8f693bfd34 100644
--- a/tests/admin_scripts/tests.py
+++ b/tests/admin_scripts/tests.py
@@ -379,14 +379,14 @@ class DjangoAdminMinimalSettings(AdminScriptTestCase):
args = ['sqlall', '--settings=test_project.settings', 'admin_scripts']
out, err = self.run_django_admin(args)
self.assertNoOutput(out)
- self.assertOutput(err, 'App with label admin_scripts could not be found')
+ self.assertOutput(err, "No app with label 'admin_scripts'.")
def test_builtin_with_environment(self):
"minimal: django-admin builtin commands fail if settings are provided in the environment"
args = ['sqlall', 'admin_scripts']
out, err = self.run_django_admin(args, 'test_project.settings')
self.assertNoOutput(out)
- self.assertOutput(err, 'App with label admin_scripts could not be found')
+ self.assertOutput(err, "No app with label 'admin_scripts'.")
def test_builtin_with_bad_settings(self):
"minimal: django-admin builtin commands fail if settings file (from argument) doesn't exist"
@@ -815,21 +815,21 @@ class ManageMinimalSettings(AdminScriptTestCase):
args = ['sqlall', 'admin_scripts']
out, err = self.run_manage(args)
self.assertNoOutput(out)
- self.assertOutput(err, 'App with label admin_scripts could not be found')
+ self.assertOutput(err, "No app with label 'admin_scripts'.")
def test_builtin_with_settings(self):
"minimal: manage.py builtin commands fail if settings are provided as argument"
args = ['sqlall', '--settings=test_project.settings', 'admin_scripts']
out, err = self.run_manage(args)
self.assertNoOutput(out)
- self.assertOutput(err, 'App with label admin_scripts could not be found')
+ self.assertOutput(err, "No app with label 'admin_scripts'.")
def test_builtin_with_environment(self):
"minimal: manage.py builtin commands fail if settings are provided in the environment"
args = ['sqlall', 'admin_scripts']
out, err = self.run_manage(args, 'test_project.settings')
self.assertNoOutput(out)
- self.assertOutput(err, 'App with label admin_scripts could not be found')
+ self.assertOutput(err, "No app with label 'admin_scripts'.")
def test_builtin_with_bad_settings(self):
"minimal: manage.py builtin commands fail if settings file (from argument) doesn't exist"
@@ -964,7 +964,7 @@ class ManageMultipleSettings(AdminScriptTestCase):
args = ['sqlall', 'admin_scripts']
out, err = self.run_manage(args)
self.assertNoOutput(out)
- self.assertOutput(err, 'App with label admin_scripts could not be found.')
+ self.assertOutput(err, "No app with label 'admin_scripts'.")
def test_builtin_with_settings(self):
"multiple: manage.py builtin commands succeed if settings are provided as argument"
@@ -1442,13 +1442,13 @@ class CommandTypes(AdminScriptTestCase):
"User AppCommands can execute when a single app name is provided"
args = ['app_command', 'NOT_AN_APP']
out, err = self.run_manage(args)
- self.assertOutput(err, "App with label NOT_AN_APP could not be found")
+ self.assertOutput(err, "No app with label 'NOT_AN_APP'.")
def test_app_command_some_invalid_appnames(self):
"User AppCommands can execute when some of the provided app names are invalid"
args = ['app_command', 'auth', 'NOT_AN_APP']
out, err = self.run_manage(args)
- self.assertOutput(err, "App with label NOT_AN_APP could not be found")
+ self.assertOutput(err, "No app with label 'NOT_AN_APP'.")
def test_label_command(self):
"User LabelCommands can execute when a label is provided"