mirror of https://github.com/django/django.git
Removed the only_installed argument of get_app_config[s].
It wasn't used anywhere and couldn't be implemented any more since non-installed apps no longer have a configuration.
This commit is contained in:
parent
742ed9878e
commit
972babc3b4
|
@ -136,29 +136,22 @@ class AppCache(object):
|
|||
"""
|
||||
return self.loaded
|
||||
|
||||
def get_app_configs(self, only_installed=True, only_with_models_module=False):
|
||||
def get_app_configs(self, only_with_models_module=False):
|
||||
"""
|
||||
Return an iterable of application configurations.
|
||||
|
||||
If only_installed is True (default), only applications explicitly
|
||||
listed in INSTALLED_APPS are considered.
|
||||
|
||||
If only_with_models_module in True (non-default), only applications
|
||||
containing a models module are considered.
|
||||
"""
|
||||
if not only_installed:
|
||||
raise ValueError("only_installed=False isn't supported any more.")
|
||||
self.populate()
|
||||
for app_config in self.app_configs.values():
|
||||
if only_installed and not app_config.installed:
|
||||
continue
|
||||
if only_with_models_module and app_config.models_module is None:
|
||||
continue
|
||||
if self.available_apps is not None and app_config.name not in self.available_apps:
|
||||
continue
|
||||
yield app_config
|
||||
|
||||
def get_app_config(self, app_label, only_installed=True, only_with_models_module=False):
|
||||
def get_app_config(self, app_label, only_with_models_module=False):
|
||||
"""
|
||||
Returns the application configuration for the given app_label.
|
||||
|
||||
|
@ -167,20 +160,13 @@ class AppCache(object):
|
|||
Raises UnavailableApp when set_available_apps() disables the
|
||||
application with this app_label.
|
||||
|
||||
If only_installed is True (default), only applications explicitly
|
||||
listed in INSTALLED_APPS are considered.
|
||||
|
||||
If only_with_models_module in True (non-default), only applications
|
||||
containing a models module are considered.
|
||||
"""
|
||||
if not only_installed:
|
||||
raise ValueError("only_installed=False isn't supported any more.")
|
||||
self.populate()
|
||||
app_config = self.app_configs.get(app_label)
|
||||
if app_config is None:
|
||||
raise LookupError("No app with label %r." % app_label)
|
||||
if only_installed and not app_config.installed:
|
||||
raise LookupError("App with label %r isn't in INSTALLED_APPS." % app_label)
|
||||
raise LookupError("No installed app with label %r." % app_label)
|
||||
if only_with_models_module and app_config.models_module is None:
|
||||
raise LookupError("App with label %r doesn't have a models module." % app_label)
|
||||
if self.available_apps is not None and app_config.name not in self.available_apps:
|
||||
|
|
|
@ -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, "No app with label 'admin_scripts'.")
|
||||
self.assertOutput(err, "No installed 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, "No app with label 'admin_scripts'.")
|
||||
self.assertOutput(err, "No installed 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, "No app with label 'admin_scripts'.")
|
||||
self.assertOutput(err, "No installed 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, "No app with label 'admin_scripts'.")
|
||||
self.assertOutput(err, "No installed 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, "No app with label 'admin_scripts'.")
|
||||
self.assertOutput(err, "No installed 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, "No app with label 'admin_scripts'.")
|
||||
self.assertOutput(err, "No installed 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, "No app with label 'NOT_AN_APP'.")
|
||||
self.assertOutput(err, "No installed 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, "No app with label 'NOT_AN_APP'.")
|
||||
self.assertOutput(err, "No installed app with label 'NOT_AN_APP'.")
|
||||
|
||||
def test_label_command(self):
|
||||
"User LabelCommands can execute when a label is provided"
|
||||
|
|
Loading…
Reference in New Issue