Fixed #31155 -- Fixed a system check for the longest choice when a named group contains only non-string values.

Regression in b6251956b6.

Thanks Murat Guchetl for the report.
This commit is contained in:
Mariusz Felisiak 2020-01-11 19:47:36 +01:00 committed by GitHub
parent 8b3e714ecf
commit 6f7998adc7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 2 deletions

View file

@ -1,4 +1,5 @@
import unittest
import uuid
from django.core.checks import Error, Warning as DjangoWarning
from django.db import connection, models
@ -769,3 +770,20 @@ class TextFieldTests(TestCase):
id='fields.W162',
)
])
@isolate_apps('invalid_models_tests')
class UUIDFieldTests(TestCase):
def test_choices_named_group(self):
class Model(models.Model):
field = models.UUIDField(
choices=[
['knights', [
[uuid.UUID('5c859437-d061-4847-b3f7-e6b78852f8c8'), 'Lancelot'],
[uuid.UUID('c7853ec1-2ea3-4359-b02d-b54e8f1bcee2'), 'Galahad'],
]],
[uuid.UUID('25d405be-4895-4d50-9b2e-d6695359ce47'), 'Other'],
],
)
self.assertEqual(Model._meta.get_field('field').check(), [])