Fixed #21634 -- Prevented hiding ImproperlyConfigured when command not found
Thanks nikolay.v.golub@gmail.com for the report.
This commit is contained in:
parent
cb15231888
commit
f5d4b45df1
|
@ -262,10 +262,10 @@ class ManagementUtility(object):
|
|||
# Output an extra note if settings are not properly configured
|
||||
try:
|
||||
settings.INSTALLED_APPS
|
||||
except ImproperlyConfigured as e:
|
||||
except ImproperlyConfigured as err:
|
||||
usage.append(style.NOTICE(
|
||||
"Note that only Django core commands are listed as settings "
|
||||
"are not properly configured (error: %s)." % e))
|
||||
"are not properly configured (error: %s)." % err))
|
||||
|
||||
return '\n'.join(usage)
|
||||
|
||||
|
@ -280,6 +280,8 @@ class ManagementUtility(object):
|
|||
try:
|
||||
app_name = commands[subcommand]
|
||||
except KeyError:
|
||||
# This might trigger ImproperlyConfigured (masked in get_commands)
|
||||
settings.INSTALLED_APPS
|
||||
sys.stderr.write("Unknown command: %r\nType '%s help' for usage.\n" %
|
||||
(subcommand, self.prog_name))
|
||||
sys.exit(1)
|
||||
|
|
|
@ -275,7 +275,7 @@ class DjangoAdminDefaultSettings(AdminScriptTestCase):
|
|||
args = ['noargs_command']
|
||||
out, err = self.run_django_admin(args)
|
||||
self.assertNoOutput(out)
|
||||
self.assertOutput(err, "Unknown command: 'noargs_command'")
|
||||
self.assertOutput(err, "settings are not configured")
|
||||
|
||||
def test_custom_command_with_settings(self):
|
||||
"default: django-admin can execute user commands if settings are provided as argument"
|
||||
|
@ -342,7 +342,7 @@ class DjangoAdminFullPathDefaultSettings(AdminScriptTestCase):
|
|||
args = ['noargs_command']
|
||||
out, err = self.run_django_admin(args)
|
||||
self.assertNoOutput(out)
|
||||
self.assertOutput(err, "Unknown command: 'noargs_command'")
|
||||
self.assertOutput(err, "settings are not configured")
|
||||
|
||||
def test_custom_command_with_settings(self):
|
||||
"fulldefault: django-admin can execute user commands if settings are provided as argument"
|
||||
|
@ -409,7 +409,7 @@ class DjangoAdminMinimalSettings(AdminScriptTestCase):
|
|||
args = ['noargs_command']
|
||||
out, err = self.run_django_admin(args)
|
||||
self.assertNoOutput(out)
|
||||
self.assertOutput(err, "Unknown command: 'noargs_command'")
|
||||
self.assertOutput(err, "settings are not configured")
|
||||
|
||||
def test_custom_command_with_settings(self):
|
||||
"minimal: django-admin can't execute user commands, even if settings are provided as argument"
|
||||
|
@ -476,7 +476,7 @@ class DjangoAdminAlternateSettings(AdminScriptTestCase):
|
|||
args = ['noargs_command']
|
||||
out, err = self.run_django_admin(args)
|
||||
self.assertNoOutput(out)
|
||||
self.assertOutput(err, "Unknown command: 'noargs_command'")
|
||||
self.assertOutput(err, "settings are not configured")
|
||||
|
||||
def test_custom_command_with_settings(self):
|
||||
"alternate: django-admin can execute user commands if settings are provided as argument"
|
||||
|
@ -546,7 +546,7 @@ class DjangoAdminMultipleSettings(AdminScriptTestCase):
|
|||
args = ['noargs_command']
|
||||
out, err = self.run_django_admin(args)
|
||||
self.assertNoOutput(out)
|
||||
self.assertOutput(err, "Unknown command: 'noargs_command'")
|
||||
self.assertOutput(err, "settings are not configured")
|
||||
|
||||
def test_custom_command_with_settings(self):
|
||||
"alternate: django-admin can execute user commands if settings are provided as argument"
|
||||
|
@ -620,7 +620,7 @@ class DjangoAdminSettingsDirectory(AdminScriptTestCase):
|
|||
args = ['noargs_command']
|
||||
out, err = self.run_django_admin(args)
|
||||
self.assertNoOutput(out)
|
||||
self.assertOutput(err, "Unknown command: 'noargs_command'")
|
||||
self.assertOutput(err, "settings are not configured")
|
||||
|
||||
def test_builtin_with_settings(self):
|
||||
"directory: django-admin builtin commands succeed if settings are provided as argument"
|
||||
|
|
Loading…
Reference in New Issue