summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Yurchenko <urchenko88@gmail.com>2016-08-02 22:19:01 +0300
committerTim Graham <timograham@gmail.com>2016-08-03 09:14:01 -0400
commit4e64e3bb6e96a50b057bc1144fba3efdee7dfc10 (patch)
tree067de408fe4ce1c22366eecf51a57fad404ce1ee
parentf4b1f972dc69e519a78182353e43701a17bb43aa (diff)
Fixed #26997 -- Fixed checks crash with empty Meta.default_permissions.
-rw-r--r--django/contrib/auth/checks.py5
-rw-r--r--docs/releases/1.10.1.txt3
-rw-r--r--tests/auth_tests/test_checks.py7
3 files changed, 14 insertions, 1 deletions
diff --git a/django/contrib/auth/checks.py b/django/contrib/auth/checks.py
index e7b5815cbd..27a28b5172 100644
--- a/django/contrib/auth/checks.py
+++ b/django/contrib/auth/checks.py
@@ -111,7 +111,10 @@ def check_models_permissions(app_configs=None, **kwargs):
opts = model._meta
builtin_permissions = dict(_get_builtin_permissions(opts))
# Check builtin permission name length.
- max_builtin_permission_name_length = max(len(name) for name in builtin_permissions.values())
+ max_builtin_permission_name_length = (
+ max(len(name) for name in builtin_permissions.values())
+ if builtin_permissions else 0
+ )
if max_builtin_permission_name_length > permission_name_max_length:
verbose_name_max_length = (
permission_name_max_length - (max_builtin_permission_name_length - len(opts.verbose_name_raw))
diff --git a/docs/releases/1.10.1.txt b/docs/releases/1.10.1.txt
index 97b616bc1d..66ff4707f7 100644
--- a/docs/releases/1.10.1.txt
+++ b/docs/releases/1.10.1.txt
@@ -17,3 +17,6 @@ Bugfixes
* Removed the broken ``BaseCommand.usage()`` method which was for
``optparse`` support (:ticket:`27000`).
+
+* Fixed a checks framework crash with an empty ``Meta.default_permissions``
+ (:ticket:`26997`).
diff --git a/tests/auth_tests/test_checks.py b/tests/auth_tests/test_checks.py
index 962444fb60..8dca3159d1 100644
--- a/tests/auth_tests/test_checks.py
+++ b/tests/auth_tests/test_checks.py
@@ -195,3 +195,10 @@ class ModelsPermissionsChecksTests(SimpleTestCase):
id='auth.E008',
),
])
+
+ def test_empty_default_permissions(self):
+ class Checked(models.Model):
+ class Meta:
+ default_permissions = ()
+
+ self.assertEqual(checks.run_checks(self.apps.get_app_configs()), [])