From ea60b7bc7464808e34e3cb0aac04455fdd8545eb Mon Sep 17 00:00:00 2001 From: Matthias Kestenholz Date: Sat, 23 Mar 2019 17:04:39 +0100 Subject: Removed redundant model field choices tests. --- tests/model_fields/models.py | 2 ++ tests/model_fields/tests.py | 6 ++++++ 2 files changed, 8 insertions(+) (limited to 'tests/model_fields') diff --git a/tests/model_fields/models.py b/tests/model_fields/models.py index 93e424a2aa..cbf3ec26ea 100644 --- a/tests/model_fields/models.py +++ b/tests/model_fields/models.py @@ -12,6 +12,7 @@ from django.db.models.fields.files import ImageField, ImageFieldFile from django.db.models.fields.related import ( ForeignKey, ForeignObject, ManyToManyField, OneToOneField, ) +from django.utils.translation import gettext_lazy as _ try: from PIL import Image @@ -46,6 +47,7 @@ class Whiz(models.Model): ) ), (0, 'Other'), + (5, _('translated')), ) c = models.IntegerField(choices=CHOICES, null=True) diff --git a/tests/model_fields/tests.py b/tests/model_fields/tests.py index f55175aa9e..bb82c7b93d 100644 --- a/tests/model_fields/tests.py +++ b/tests/model_fields/tests.py @@ -162,6 +162,12 @@ class GetFieldDisplayTests(SimpleTestCase): self.assertEqual(Whiz(c='').get_c_display(), '') # Empty value self.assertEqual(WhizDelayed(c=0).get_c_display(), 'Other') # Delayed choices + def test_get_FIELD_display_translated(self): + """A translated display value is coerced to str.""" + val = Whiz(c=5).get_c_display() + self.assertIsInstance(val, str) + self.assertEqual(val, 'translated') + def test_iterator_choices(self): """ get_choices() works with Iterators. -- cgit v1.3