1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #32285 -- Raised ImproperlyConfigured when AppConfig.label is not a valid Python identifier.

This commit is contained in:
Hasan Ramezani
2020-12-21 14:21:25 +01:00
committed by Mariusz Felisiak
parent 110001d0bb
commit 8b2a30f6f1
2 changed files with 12 additions and 0 deletions

View File

@@ -436,6 +436,14 @@ class AppConfigTests(SimpleTestCase):
ac = AppConfig('label', Stub(__path__=['a']))
self.assertEqual(repr(ac), '<AppConfig: label>')
def test_invalid_label(self):
class MyAppConfig(AppConfig):
label = 'invalid.label'
msg = "The app label 'invalid.label' is not a valid Python identifier."
with self.assertRaisesMessage(ImproperlyConfigured, msg):
MyAppConfig('test_app', Stub())
@override_settings(
INSTALLED_APPS=['apps.apps.ModelPKAppsConfig'],
DEFAULT_AUTO_FIELD='django.db.models.SmallAutoField',