From 8b2a30f6f16cb1f3538847954030d69da005bc7f Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Mon, 21 Dec 2020 14:21:25 +0100 Subject: Fixed #32285 -- Raised ImproperlyConfigured when AppConfig.label is not a valid Python identifier. --- tests/apps/tests.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/apps') diff --git a/tests/apps/tests.py b/tests/apps/tests.py index 0e1f918bcc..a8a93ce683 100644 --- a/tests/apps/tests.py +++ b/tests/apps/tests.py @@ -436,6 +436,14 @@ class AppConfigTests(SimpleTestCase): ac = AppConfig('label', Stub(__path__=['a'])) self.assertEqual(repr(ac), '') + 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', -- cgit v1.3