summaryrefslogtreecommitdiff
path: root/tests/admin_docs
diff options
context:
space:
mode:
authorHelen Sherwood-Taylor <helen@rrdlabs.co.uk>2016-08-12 19:07:24 +0100
committerTim Graham <timograham@gmail.com>2016-08-20 10:02:22 -0400
commitae0f55eb491255217d6df31296ec8102007224a6 (patch)
treecac9bf607a4ba6483585350d55a74b3f2f8eea1b /tests/admin_docs
parent7c0c3fb6b1d932bc33e7dcc8f16e31cd39992f9b (diff)
[1.10.x] Fixed #27018 -- Fixed admindocs crash with a view in a class.
Generated correct admindocs URLs on Python 3. URLs generate 404s on Python 2, as in older versions of Django. Backport of bc1e2d8e8edde6cc7d2657c68242a13ee65a15b8 from master
Diffstat (limited to 'tests/admin_docs')
-rw-r--r--tests/admin_docs/tests.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/admin_docs/tests.py b/tests/admin_docs/tests.py
index e3091738a8..26e9c04d29 100644
--- a/tests/admin_docs/tests.py
+++ b/tests/admin_docs/tests.py
@@ -9,6 +9,7 @@ from django.contrib.sites.models import Site
from django.test import TestCase, modify_settings, override_settings
from django.test.utils import captured_stderr
from django.urls import reverse
+from django.utils import six
from .models import Company, Person
@@ -82,6 +83,18 @@ class AdminDocViewTests(TestDataMixin, AdminDocsTestCase):
self.assertContains(response, 'Views by namespace test')
self.assertContains(response, 'Name: <code>test:func</code>.')
+ @unittest.skipIf(six.PY2, "Python 2 doesn't support __qualname__.")
+ def test_view_index_with_method(self):
+ """
+ Views that are methods are listed correctly.
+ """
+ response = self.client.get(reverse('django-admindocs-views-index'))
+ self.assertContains(
+ response,
+ '<h3><a href="/admindocs/views/django.contrib.admin.sites.AdminSite.index/">/admin/</a></h3>',
+ html=True
+ )
+
def test_view_detail(self):
url = reverse('django-admindocs-views-detail', args=['django.contrib.admindocs.views.BaseAdminDocsView'])
response = self.client.get(url)
@@ -103,6 +116,14 @@ class AdminDocViewTests(TestDataMixin, AdminDocsTestCase):
self.assertEqual(response.status_code, 404)
self.assertNotIn("urlpatterns_reverse.nonimported_module", sys.modules)
+ def test_view_detail_as_method(self):
+ """
+ Views that are methods can be displayed.
+ """
+ url = reverse('django-admindocs-views-detail', args=['django.contrib.admin.sites.AdminSite.index'])
+ response = self.client.get(url)
+ self.assertEqual(response.status_code, 200 if six.PY3 else 404)
+
def test_model_index(self):
response = self.client.get(reverse('django-admindocs-models-index'))
self.assertContains(