summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMatthias Kestenholz <mk@feinheit.ch>2019-03-22 13:21:00 +0100
committerTim Graham <timograham@gmail.com>2019-03-22 13:01:15 -0400
commita86ffb3e0fd8a37ff1b9affc177e81ef9298ec36 (patch)
tree8bf01584d7bfe84199e4d9ae31805dd5cd58b42d /tests
parent8cff329802182b6f5147a6a43c1f0e11d40ec1fc (diff)
[2.2.x] Fixed #30280 -- Restored Model.get_FIELD_display()'s coercion of lazy strings.
Reverted cc79c7ee637e65c8da27e56d746c87903d5ec901. Backport of ea071870f943c23a8eaf36dfcdf382afd6478fd1 from master.
Diffstat (limited to 'tests')
-rw-r--r--tests/choices/models.py5
-rw-r--r--tests/choices/tests.py3
2 files changed, 6 insertions, 2 deletions
diff --git a/tests/choices/models.py b/tests/choices/models.py
index b4ef8954ab..37ef8daf60 100644
--- a/tests/choices/models.py
+++ b/tests/choices/models.py
@@ -10,12 +10,13 @@ field. This method returns the "human-readable" value of the field.
"""
from django.db import models
+from django.utils.translation import gettext_lazy as _
class Person(models.Model):
GENDER_CHOICES = (
- ('M', 'Male'),
- ('F', 'Female'),
+ ('M', _('Male')),
+ ('F', _('Female')),
)
name = models.CharField(max_length=20)
gender = models.CharField(max_length=1, choices=GENDER_CHOICES)
diff --git a/tests/choices/tests.py b/tests/choices/tests.py
index 329c936c7f..88b8bf7fe2 100644
--- a/tests/choices/tests.py
+++ b/tests/choices/tests.py
@@ -20,3 +20,6 @@ class ChoicesTests(TestCase):
a.gender = 'U'
self.assertEqual(a.get_gender_display(), 'U')
+
+ # _get_FIELD_display() coerces lazy strings.
+ self.assertIsInstance(a.get_gender_display(), str)