diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py
index 98f75e0..69a3ba8 100644
a
|
b
|
def get_commands():
|
102 | 102 | _commands = dict([(name, 'django.core') for name in find_commands(__path__[0])]) |
103 | 103 | |
104 | 104 | # Find the installed apps |
| 105 | from django.conf import settings |
105 | 106 | try: |
106 | | from django.conf import settings |
107 | 107 | apps = settings.INSTALLED_APPS |
108 | | except (AttributeError, EnvironmentError, ImportError): |
| 108 | except ImportError: |
| 109 | # Still useful for commands that do not require functional settings, |
| 110 | # like startproject or help |
109 | 111 | apps = [] |
110 | 112 | |
111 | 113 | # Find and load the management module for each installed app. |
diff --git a/tests/regressiontests/admin_scripts/tests.py b/tests/regressiontests/admin_scripts/tests.py
index a8fc7ed..a149940 100644
a
|
b
|
class ManageMultipleSettings(AdminScriptTestCase):
|
981 | 981 | |
982 | 982 | class ManageSettingsWithImportError(AdminScriptTestCase): |
983 | 983 | """Tests for manage.py when using the default settings.py file |
984 | | with an import error. Ticket #14130. |
| 984 | containing errors. |
985 | 985 | """ |
986 | | def setUp(self): |
987 | | self.write_settings_with_import_error('settings.py') |
988 | | |
989 | 986 | def tearDown(self): |
990 | 987 | self.remove_settings('settings.py') |
991 | 988 | |
… |
… |
class ManageSettingsWithImportError(AdminScriptTestCase):
|
1000 | 997 | settings_file.write('# Settings file automatically generated by regressiontests.admin_scripts test case\n') |
1001 | 998 | settings_file.write('# The next line will cause an import error:\nimport foo42bar\n') |
1002 | 999 | |
1003 | | def test_builtin_command(self): |
1004 | | "import error: manage.py builtin commands shows useful diagnostic info when settings with import errors is provided" |
| 1000 | def test_builtin_command_with_import_error(self): |
| 1001 | """ |
| 1002 | import error: manage.py builtin commands shows useful diagnostic info |
| 1003 | when settings with import errors is provided (#14130). |
| 1004 | """ |
| 1005 | self.write_settings_with_import_error('settings.py') |
1005 | 1006 | args = ['sqlall', 'admin_scripts'] |
1006 | 1007 | out, err = self.run_manage(args) |
1007 | 1008 | self.assertNoOutput(out) |
1008 | 1009 | self.assertOutput(err, "No module named foo42bar") |
1009 | 1010 | |
| 1011 | def test_builtin_command_with_attribute_error(self): |
| 1012 | """ |
| 1013 | manage.py builtin commands does not swallow attribute errors from bad settings (#18845) |
| 1014 | """ |
| 1015 | self.write_settings('settings.py', sdict={'BAD_VAR': 'INSTALLED_APPS.crash'}) |
| 1016 | args = ['collectstatic', 'admin_scripts'] |
| 1017 | out, err = self.run_manage(args) |
| 1018 | self.assertNoOutput(out) |
| 1019 | self.assertOutput(err, "AttributeError: 'list' object has no attribute 'crash'") |
| 1020 | |
| 1021 | |
1010 | 1022 | class ManageValidate(AdminScriptTestCase): |
1011 | 1023 | def tearDown(self): |
1012 | 1024 | self.remove_settings('settings.py') |