From 920448539631b52dcee53bd32a880abbc9de18bd Mon Sep 17 00:00:00 2001 From: Nick Pope Date: Wed, 13 Jan 2021 16:19:22 +0000 Subject: Fixed #16117 -- Added decorators for admin action and display functions. Refs #25134, #32099. --- tests/admin_utils/tests.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'tests/admin_utils/tests.py') 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), -- cgit v1.3