summaryrefslogtreecommitdiff
path: root/tests/admin_docs
diff options
context:
space:
mode:
authorRamon Saraiva <ramonsaraiva@gmail.com>2021-02-10 09:33:57 -0300
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-02-11 06:50:50 +0100
commitdcb094abe8cff505c4824532a8375f5edef407d5 (patch)
treecd5c5417120ab78f776b9316ba3b9ac0bca822f0 /tests/admin_docs
parent4372233ebf9acef606f3d2f7be4d6ba73b168084 (diff)
downloaddjango-dcb094abe8cff505c4824532a8375f5edef407d5.tar.gz
Fixed #32421 -- Made admindocs ModelDetailView show model cached properties.
Diffstat (limited to 'tests/admin_docs')
-rw-r--r--tests/admin_docs/models.py5
-rw-r--r--tests/admin_docs/test_views.py4
2 files changed, 9 insertions, 0 deletions
diff --git a/tests/admin_docs/models.py b/tests/admin_docs/models.py
index 02bf1efa9f..06569d5c4c 100644
--- a/tests/admin_docs/models.py
+++ b/tests/admin_docs/models.py
@@ -3,6 +3,7 @@ Models for testing various aspects of the djang.contrib.admindocs app
"""
from django.db import models
+from django.utils.functional import cached_property
class Company(models.Model):
@@ -56,6 +57,10 @@ class Person(models.Model):
def a_property(self):
return 'a_property'
+ @cached_property
+ def a_cached_property(self):
+ return 'a_cached_property'
+
def suffix_company_name(self, suffix='ltd'):
return self.company.name + suffix
diff --git a/tests/admin_docs/test_views.py b/tests/admin_docs/test_views.py
index 266ee98bf8..8e09c4cfec 100644
--- a/tests/admin_docs/test_views.py
+++ b/tests/admin_docs/test_views.py
@@ -232,6 +232,10 @@ class TestModelDetailView(TestDataMixin, AdminDocsTestCase):
"""Model properties are displayed as fields."""
self.assertContains(self.response, '<td>a_property</td>')
+ def test_instance_of_cached_property_methods_are_displayed(self):
+ """Model cached properties are displayed as fields."""
+ self.assertContains(self.response, '<td>a_cached_property</td>')
+
def test_method_data_types(self):
company = Company.objects.create(name="Django")
person = Person.objects.create(first_name="Human", last_name="User", company=company)