diff options
Diffstat (limited to 'tests/admin_utils/tests.py')
| -rw-r--r-- | tests/admin_utils/tests.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/tests/admin_utils/tests.py b/tests/admin_utils/tests.py index ce9f94dbb9..a74449bdc0 100644 --- a/tests/admin_utils/tests.py +++ b/tests/admin_utils/tests.py @@ -3,6 +3,7 @@ from decimal import Decimal from django import forms from django.conf import settings +from django.contrib import admin from django.contrib.admin import helpers from django.contrib.admin.utils import ( NestedObjects, display_for_field, display_for_value, flatten, @@ -293,9 +294,9 @@ class UtilsTests(SimpleTestCase): self.assertEqual(label_for_field('site_id', Article), 'Site id') class MockModelAdmin: + @admin.display(description='not Really the Model') def test_from_model(self, obj): return "nothing" - test_from_model.short_description = "not Really the Model" self.assertEqual( label_for_field("test_from_model", Article, model_admin=MockModelAdmin), @@ -323,13 +324,11 @@ class UtilsTests(SimpleTestCase): label_for_field('nonexistent', Article, form=ArticleForm()), def test_label_for_property(self): - # NOTE: cannot use @property decorator, because of - # AttributeError: 'property' object has no attribute 'short_description' class MockModelAdmin: - def my_property(self): + @property + @admin.display(description='property short description') + def test_from_property(self): return "this if from property" - my_property.short_description = 'property short description' - test_from_property = property(my_property) self.assertEqual( label_for_field("test_from_property", Article, model_admin=MockModelAdmin), |
