diff options
| author | Helen Sherwood-Taylor <helen@rrdlabs.co.uk> | 2016-08-12 19:07:24 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-08-20 10:01:57 -0400 |
| commit | bc1e2d8e8edde6cc7d2657c68242a13ee65a15b8 (patch) | |
| tree | 2de98fbc0a4b8202b6272484029d29cab553adb3 /tests/admin_docs | |
| parent | 00bb47b58f974277330f9845aee0702f7a46d736 (diff) | |
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.
Diffstat (limited to 'tests/admin_docs')
| -rw-r--r-- | tests/admin_docs/tests.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/admin_docs/tests.py b/tests/admin_docs/tests.py index 82384a4bb8..f57a9c8117 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( |
