Fixed #29768 -- Improved error message when an AppConfig has a typo in INSTALLED_APPS.

This commit is contained in:
Marten Kenbeek 2018-09-18 18:19:18 +02:00 committed by Tim Graham
parent 2349cbd909
commit 40c8ffad72
2 changed files with 27 additions and 6 deletions

View file

@ -81,10 +81,18 @@ class AppsTests(SimpleTestCase):
pass
def test_no_such_app_config(self):
"""
Tests when INSTALLED_APPS contains an entry that doesn't exist.
"""
with self.assertRaises(ImportError):
msg = "No module named 'apps.NoSuchConfig'"
with self.assertRaisesMessage(ImportError, msg):
with self.settings(INSTALLED_APPS=['apps.NoSuchConfig']):
pass
def test_no_such_app_config_with_choices(self):
msg = (
"'apps.apps' does not contain a class 'NoSuchConfig'. Choices are: "
"'BadConfig', 'MyAdmin', 'MyAuth', 'NoSuchApp', 'PlainAppsConfig', "
"'RelabeledAppsConfig'."
)
with self.assertRaisesMessage(ImproperlyConfigured, msg):
with self.settings(INSTALLED_APPS=['apps.apps.NoSuchConfig']):
pass