diff --git a/tests/admin_utils/tests.py b/tests/admin_utils/tests.py
index 0adee38afa..582ed23b4d 100644
--- a/tests/admin_utils/tests.py
+++ b/tests/admin_utils/tests.py
@@ -149,43 +149,33 @@ class UtilsTests(SimpleTestCase):
self.assertEqual(value, resolved_value)
- def test_null_display_for_field(self):
- """
- Regression test for #12550: display_for_field should handle None
- value.
- """
- display_value = display_for_field(None, models.CharField(), self.empty_value)
- self.assertEqual(display_value, self.empty_value)
+ def test_empty_value_display_for_field(self):
+ tests = [
+ models.CharField(),
+ models.DateField(),
+ models.DecimalField(),
+ models.FloatField(),
+ models.JSONField(),
+ models.TimeField(),
+ ]
+ for model_field in tests:
+ with self.subTest(model_field=model_field):
+ display_value = display_for_field(None, model_field, self.empty_value)
+ self.assertEqual(display_value, self.empty_value)
- display_value = display_for_field(
- None, models.CharField(choices=((None, "test_none"),)), self.empty_value
- )
+ def test_empty_value_display_choices(self):
+ model_field = models.CharField(choices=((None, "test_none"),))
+ display_value = display_for_field(None, model_field, self.empty_value)
self.assertEqual(display_value, "test_none")
- display_value = display_for_field(None, models.DateField(), self.empty_value)
- self.assertEqual(display_value, self.empty_value)
-
- display_value = display_for_field(None, models.TimeField(), self.empty_value)
- self.assertEqual(display_value, self.empty_value)
-
- display_value = display_for_field(
- None, models.BooleanField(null=True), self.empty_value
- )
+ def test_empty_value_display_booleanfield(self):
+ model_field = models.BooleanField(null=True)
+ display_value = display_for_field(None, model_field, self.empty_value)
expected = (
- ''
- % settings.STATIC_URL
+ f''
)
self.assertHTMLEqual(display_value, expected)
- display_value = display_for_field(None, models.DecimalField(), self.empty_value)
- self.assertEqual(display_value, self.empty_value)
-
- display_value = display_for_field(None, models.FloatField(), self.empty_value)
- self.assertEqual(display_value, self.empty_value)
-
- display_value = display_for_field(None, models.JSONField(), self.empty_value)
- self.assertEqual(display_value, self.empty_value)
-
def test_json_display_for_field(self):
tests = [
({"a": {"b": "c"}}, '{"a": {"b": "c"}}'),