summaryrefslogtreecommitdiff
path: root/tests/admin_utils/tests.py
diff options
context:
space:
mode:
authorNick Pope <nick.pope@flightdataservices.com>2021-01-13 16:19:22 +0000
committerGitHub <noreply@github.com>2021-01-13 17:19:22 +0100
commit920448539631b52dcee53bd32a880abbc9de18bd (patch)
tree03dd52fd206088302de11e0b485b420726718a4a /tests/admin_utils/tests.py
parent83fcfc9ec8610540948815e127101f1206562ead (diff)
Fixed #16117 -- Added decorators for admin action and display functions.
Refs #25134, #32099.
Diffstat (limited to 'tests/admin_utils/tests.py')
-rw-r--r--tests/admin_utils/tests.py11
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),