summaryrefslogtreecommitdiff
path: root/tests/invalid_models_tests/test_ordinary_fields.py
diff options
context:
space:
mode:
authorFrançois Freitag <mail@franek.fr>2018-01-24 20:21:13 -0800
committerTim Graham <timograham@gmail.com>2018-01-27 09:19:56 -0500
commit3aa9ab39cce6b2a27d6334ad0148c8f37b6f5986 (patch)
tree220dac961b3ef6bdbabe3fb45d2c472d69213a2b /tests/invalid_models_tests/test_ordinary_fields.py
parentb002a032f90b8cd228cfcee6c88cd238a8191cc0 (diff)
Refs #28748 -- Reallowed lazy values in model field choices.
Regression in f9844f484186fa13399bf8b96f58616687fe158a. Thanks Matthias Kestenholz for the report and suggestions.
Diffstat (limited to 'tests/invalid_models_tests/test_ordinary_fields.py')
-rw-r--r--tests/invalid_models_tests/test_ordinary_fields.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/invalid_models_tests/test_ordinary_fields.py b/tests/invalid_models_tests/test_ordinary_fields.py
index 75e6148f98..281779828d 100644
--- a/tests/invalid_models_tests/test_ordinary_fields.py
+++ b/tests/invalid_models_tests/test_ordinary_fields.py
@@ -5,6 +5,7 @@ from django.db import connection, models
from django.test import SimpleTestCase, TestCase, skipIfDBFeature
from django.test.utils import isolate_apps, override_settings
from django.utils.timezone import now
+from django.utils.translation import gettext_lazy as _
@isolate_apps('invalid_models_tests')
@@ -198,6 +199,12 @@ class CharFieldTests(TestCase):
),
])
+ def test_choices_containing_lazy(self):
+ class Model(models.Model):
+ field = models.CharField(max_length=10, choices=[['1', _('1')], ['2', _('2')]])
+
+ self.assertEqual(Model._meta.get_field('field').check(), [])
+
def test_choices_named_group(self):
class Model(models.Model):
field = models.CharField(
@@ -248,6 +255,17 @@ class CharFieldTests(TestCase):
),
])
+ def test_choices_named_group_lazy(self):
+ class Model(models.Model):
+ field = models.CharField(
+ max_length=10, choices=[
+ [_('knights'), [['L', _('Lancelot')], ['G', _('Galahad')]]],
+ ['R', _('Random character')],
+ ],
+ )
+
+ self.assertEqual(Model._meta.get_field('field').check(), [])
+
def test_bad_db_index_value(self):
class Model(models.Model):
field = models.CharField(max_length=10, db_index='bad')