diff options
| author | Carlton Gibson <carlton.gibson@noumenal.es> | 2019-10-15 11:04:38 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-10-15 13:04:32 +0200 |
| commit | 1de9a92295af87846e810a40fbb9ceb6b8d3e773 (patch) | |
| tree | 3ba15d8de47f0db24f20f7aec68725ea8fea8269 | |
| parent | dee687e93a2d45e9fac404be2098cc4707d31c1f (diff) | |
Fixed #30872 -- Improved unknown command message when settings are manually configured.
| -rw-r--r-- | django/core/management/__init__.py | 2 | ||||
| -rw-r--r-- | tests/admin_scripts/tests.py | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py index adc7d173eb..cf6b60c93e 100644 --- a/django/core/management/__init__.py +++ b/django/core/management/__init__.py @@ -229,7 +229,7 @@ class ManagementUtility: # (get_commands() swallows the original one) so the user is # informed about it. settings.INSTALLED_APPS - else: + elif not settings.configured: sys.stderr.write("No Django settings specified.\n") possible_matches = get_close_matches(subcommand, commands) sys.stderr.write('Unknown command: %r' % subcommand) diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py index 1e4477ed34..de220f0282 100644 --- a/tests/admin_scripts/tests.py +++ b/tests/admin_scripts/tests.py @@ -634,6 +634,15 @@ class DjangoAdminSettingsDirectory(AdminScriptTestCase): # of the generated manage.py script ########################################################################## +class ManageManullyConfiguredSettings(AdminScriptTestCase): + """Customized manage.py calling settings.configure().""" + def test_non_existent_command_output(self): + out, err = self.run_manage(['invalid_command'], manage_py='configured_settings_manage.py') + self.assertNoOutput(out) + self.assertOutput(err, "Unknown command: 'invalid_command'") + self.assertNotInOutput(err, 'No Django settings specified') + + class ManageNoSettings(AdminScriptTestCase): "A series of tests for manage.py when there is no settings.py file." |
