summaryrefslogtreecommitdiff
path: root/tests/view_tests
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2020-07-07 16:23:54 -0700
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-09-07 06:54:19 +0200
commit11ebc6479ffda87376b60c9475d33d8120f86368 (patch)
treeccc77bccff2f90a3b16b887f975e08cbdbcf5419 /tests/view_tests
parent83dea65ed649b5e80111017cd5c476c636872b2d (diff)
Fixed #31791 -- Made technical 404 debug page display the tried URL patterns for Http404.
Diffstat (limited to 'tests/view_tests')
-rw-r--r--tests/view_tests/tests/test_debug.py30
1 files changed, 27 insertions, 3 deletions
diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py
index 6e839b44f5..6d1b3e6f48 100644
--- a/tests/view_tests/tests/test_debug.py
+++ b/tests/view_tests/tests/test_debug.py
@@ -113,13 +113,25 @@ class DebugViewTests(SimpleTestCase):
def test_404(self):
response = self.client.get('/raises404/')
self.assertEqual(response.status_code, 404)
- self.assertContains(response, '<code>not-in-urls</code>, didn’t match', status_code=404)
+ self.assertContains(
+ response,
+ '<p>The current path, <code>not-in-urls</code>, didn’t match any '
+ 'of these.</p>',
+ status_code=404,
+ html=True,
+ )
def test_404_not_in_urls(self):
response = self.client.get('/not-in-urls')
self.assertNotContains(response, "Raised by:", status_code=404)
self.assertContains(response, "Django tried these URL patterns", status_code=404)
- self.assertContains(response, '<code>not-in-urls</code>, didn’t match', status_code=404)
+ self.assertContains(
+ response,
+ '<p>The current path, <code>not-in-urls</code>, didn’t match any '
+ 'of these.</p>',
+ status_code=404,
+ html=True,
+ )
# Pattern and view name of a RegexURLPattern appear.
self.assertContains(response, r"^regex-post/(?P&lt;pk&gt;[0-9]+)/$", status_code=404)
self.assertContains(response, "[name='regex-post']", status_code=404)
@@ -130,12 +142,24 @@ class DebugViewTests(SimpleTestCase):
@override_settings(ROOT_URLCONF=WithoutEmptyPathUrls)
def test_404_empty_path_not_in_urls(self):
response = self.client.get('/')
- self.assertContains(response, 'The empty path didn’t match any of these.', status_code=404)
+ self.assertContains(
+ response,
+ '<p>The empty path didn’t match any of these.</p>',
+ status_code=404,
+ html=True,
+ )
def test_technical_404(self):
response = self.client.get('/technical404/')
self.assertContains(response, "Raised by:", status_code=404)
self.assertContains(response, "view_tests.views.technical404", status_code=404)
+ self.assertContains(
+ response,
+ '<p>The current path, <code>technical404/</code>, matched the '
+ 'last one.</p>',
+ status_code=404,
+ html=True,
+ )
def test_classbased_technical_404(self):
response = self.client.get('/classbased404/')