mirror of
https://github.com/django/django.git
synced 2025-07-30 00:24:26 +00:00
Fixed #14130 -- Made manage.py error reporting more useful when the settings.py file triggers import errors (in new projects). Thanks Setok for the report, mk and steph for their work.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15522 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
c7618d5fa6
commit
a797b7dba0
2 changed files with 34 additions and 2 deletions
|
@ -958,6 +958,35 @@ class ManageMultipleSettings(AdminScriptTestCase):
|
|||
self.assertNoOutput(out)
|
||||
self.assertOutput(err, "Unknown command: 'noargs_command'")
|
||||
|
||||
class ManageSettingsWithImportError(AdminScriptTestCase):
|
||||
"""Tests for manage.py when using the default settings.py file
|
||||
with an import error. Ticket #14130.
|
||||
"""
|
||||
def setUp(self):
|
||||
self.write_settings_with_import_error('settings.py')
|
||||
|
||||
def tearDown(self):
|
||||
self.remove_settings('settings.py')
|
||||
|
||||
def write_settings_with_import_error(self, filename, apps=None, is_dir=False, sdict=None):
|
||||
test_dir = os.path.dirname(os.path.dirname(__file__))
|
||||
if is_dir:
|
||||
settings_dir = os.path.join(test_dir,filename)
|
||||
os.mkdir(settings_dir)
|
||||
settings_file = open(os.path.join(settings_dir,'__init__.py'), 'w')
|
||||
else:
|
||||
settings_file = open(os.path.join(test_dir, filename), 'w')
|
||||
settings_file.write('# Settings file automatically generated by regressiontests.admin_scripts test case\n')
|
||||
settings_file.write('# The next line will cause an import error:\nimport foo42bar\n')
|
||||
|
||||
settings_file.close()
|
||||
|
||||
def test_builtin_command(self):
|
||||
"import error: manage.py builtin commands shows useful diagnostic info when settings with import errors is provided"
|
||||
args = ['sqlall','admin_scripts']
|
||||
out, err = self.run_manage(args)
|
||||
self.assertNoOutput(out)
|
||||
self.assertOutput(err, "ImportError: No module named foo42bar")
|
||||
|
||||
class ManageValidate(AdminScriptTestCase):
|
||||
def tearDown(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue