summaryrefslogtreecommitdiff
path: root/tests/regressiontests/admin_scripts/tests.py
diff options
context:
space:
mode:
authorKaren Tracey <kmtracey@gmail.com>2010-04-12 12:39:18 +0000
committerKaren Tracey <kmtracey@gmail.com>2010-04-12 12:39:18 +0000
commit55c31fbdefe3bc3c948599b66781e7a9a1dae2a2 (patch)
treefa67da6e07f2a4533a766c5a2c60d7e976e6404a /tests/regressiontests/admin_scripts/tests.py
parent82b8b67446f6737a22593876c8e77ff19532e2c5 (diff)
Fixed #11696: Changed app loading code so that it does not swallow import errors that used to be (prior to r10088) raised.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12950 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/admin_scripts/tests.py')
-rw-r--r--tests/regressiontests/admin_scripts/tests.py28
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/regressiontests/admin_scripts/tests.py b/tests/regressiontests/admin_scripts/tests.py
index 6a739f4029..62a1b49637 100644
--- a/tests/regressiontests/admin_scripts/tests.py
+++ b/tests/regressiontests/admin_scripts/tests.py
@@ -13,7 +13,7 @@ from django import conf, bin, get_version
from django.conf import settings
class AdminScriptTestCase(unittest.TestCase):
- def write_settings(self, filename, apps=None, is_dir=False):
+ def write_settings(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)
@@ -39,6 +39,10 @@ class AdminScriptTestCase(unittest.TestCase):
if apps:
settings_file.write("INSTALLED_APPS = %s\n" % apps)
+ if sdict:
+ for k, v in sdict.items():
+ settings_file.write("%s = %s\n" % (k, v))
+
settings_file.close()
def remove_settings(self, filename, is_dir=False):
@@ -952,6 +956,28 @@ class ManageMultipleSettings(AdminScriptTestCase):
self.assertNoOutput(out)
self.assertOutput(err, "Unknown command: 'noargs_command'")
+
+class ManageValidateImportErrorsReported(AdminScriptTestCase):
+ def tearDown(self):
+ self.remove_settings('settings.py')
+
+ def test_nonexistent_app(self):
+ "manage.py validate reports an error on a non-existent app in INSTALLED_APPS"
+ self.write_settings('settings.py', apps=['admin_scriptz.broken_app'], sdict={'USE_I18N': False})
+ args = ['validate']
+ out, err = self.run_manage(args)
+ self.assertNoOutput(out)
+ self.assertOutput(err, 'No module named admin_scriptz.broken_app')
+
+ def test_broken_app(self):
+ "manage.py validate reports an ImportError if an app's models.py raises one on import"
+ self.write_settings('settings.py', apps=['admin_scripts.broken_app'])
+ args = ['validate']
+ out, err = self.run_manage(args)
+ self.assertNoOutput(out)
+ self.assertOutput(err, 'ImportError')
+
+
##########################################################################
# COMMAND PROCESSING TESTS
# Check that user-space commands are correctly handled - in particular,