mirror of https://github.com/django/django.git
Added test for django.contrib.admin.utils.help_text_for_field().
This commit is contained in:
parent
fbe82f8255
commit
1e96de4f97
|
@ -15,7 +15,11 @@ class Article(models.Model):
|
|||
"""
|
||||
site = models.ForeignKey(Site, models.CASCADE, related_name="admin_articles")
|
||||
title = models.CharField(max_length=100)
|
||||
hist = models.CharField(max_length=100, verbose_name=_("History"))
|
||||
hist = models.CharField(
|
||||
max_length=100,
|
||||
verbose_name=_('History'),
|
||||
help_text=_('History help text'),
|
||||
)
|
||||
created = models.DateTimeField(null=True)
|
||||
|
||||
def __str__(self):
|
||||
|
|
|
@ -6,7 +6,8 @@ from django.conf import settings
|
|||
from django.contrib.admin import helpers
|
||||
from django.contrib.admin.utils import (
|
||||
NestedObjects, display_for_field, display_for_value, flatten,
|
||||
flatten_fieldsets, label_for_field, lookup_field, quote,
|
||||
flatten_fieldsets, help_text_for_field, label_for_field, lookup_field,
|
||||
quote,
|
||||
)
|
||||
from django.db import DEFAULT_DB_ALIAS, models
|
||||
from django.test import SimpleTestCase, TestCase, override_settings
|
||||
|
@ -334,6 +335,16 @@ class UtilsTests(SimpleTestCase):
|
|||
'property short description'
|
||||
)
|
||||
|
||||
def test_help_text_for_field(self):
|
||||
tests = [
|
||||
('article', ''),
|
||||
('unknown', ''),
|
||||
('hist', 'History help text'),
|
||||
]
|
||||
for name, help_text in tests:
|
||||
with self.subTest(name=name):
|
||||
self.assertEqual(help_text_for_field(name, Article), help_text)
|
||||
|
||||
def test_related_name(self):
|
||||
"""
|
||||
Regression test for #13963
|
||||
|
|
Loading…
Reference in New Issue