Add failing test for lazy text

This commit is contained in:
Ryan P Kilby 2016-11-12 03:58:09 -05:00
parent 06b1a6d65a
commit b646fa8c4d
2 changed files with 11 additions and 1 deletions

View File

@ -4,6 +4,7 @@ from __future__ import unicode_literals
from django import forms
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
REGULAR = 0
@ -45,7 +46,7 @@ class SubnetMaskField(models.Field):
@python_2_unicode_compatible
class User(models.Model):
username = models.CharField(max_length=255)
username = models.CharField(_('username'), max_length=255)
first_name = SubCharField(max_length=100)
last_name = SubSubCharField(max_length=100)

View File

@ -6,6 +6,7 @@ from django.test import TestCase, override_settings
from django.db import models
from django.db.models.constants import LOOKUP_SEP
from django.db.models.fields.related import ForeignObjectRel
from django.utils.functional import Promise
from django_filters.utils import (
get_field_parts, get_model_field, resolve_field,
@ -232,6 +233,14 @@ class VerboseFieldNameTests(TestCase):
verbose_name = verbose_field_name(Book, 'lovers__first_name')
self.assertEqual(verbose_name, 'lovers first name')
def test_lazy_text(self):
# sanity check
field = User._meta.get_field('username')
self.assertIsInstance(field.verbose_name, Promise)
verbose_name = verbose_field_name(User, 'username')
self.assertEqual(verbose_name, 'username')
class VerboseLookupExprTests(TestCase):