From c03e41712b2274f524d32bc2aef455ed82c9e3b4 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Tue, 29 May 2018 21:43:38 -0400 Subject: Refs #28748 -- Reallowed lazy model field choices. Regression in 3aa9ab39cce6b2a27d6334ad0148c8f37b6f5986. --- tests/invalid_models_tests/test_ordinary_fields.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/invalid_models_tests/test_ordinary_fields.py') diff --git a/tests/invalid_models_tests/test_ordinary_fields.py b/tests/invalid_models_tests/test_ordinary_fields.py index fb222edad3..546c16a976 100644 --- a/tests/invalid_models_tests/test_ordinary_fields.py +++ b/tests/invalid_models_tests/test_ordinary_fields.py @@ -4,6 +4,7 @@ from django.core.checks import Error, Warning as DjangoWarning 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.functional import lazy from django.utils.timezone import now from django.utils.translation import gettext_lazy as _ @@ -188,6 +189,12 @@ class CharFieldTests(TestCase): self.assertEqual(Model._meta.get_field('field').check(), []) + def test_lazy_choices(self): + class Model(models.Model): + field = models.CharField(max_length=10, choices=lazy(lambda: [[1, '1'], [2, '2']], tuple)()) + + self.assertEqual(Model._meta.get_field('field').check(), []) + def test_choices_named_group(self): class Model(models.Model): field = models.CharField( -- cgit v1.3