diff options
| author | Baptiste Mispelon <bmispelon@gmail.com> | 2013-12-07 03:21:58 +0100 |
|---|---|---|
| committer | Baptiste Mispelon <bmispelon@gmail.com> | 2013-12-07 03:21:58 +0100 |
| commit | a020dd0a99da13d0f024d42c46f01d8f503e9d5e (patch) | |
| tree | c17869df8bf43f0bfb8547bbaf4c793803d64209 /tests | |
| parent | ffc0e0ca3760759688b497ed9f580c3ebd807f80 (diff) | |
Fixed #21530 -- Prevent AttributeError in default URLconf detection code.
Thanks to @dmyerscoug for the report and original patch
and to @alasdairnicol for the added tests.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/view_tests/default_urls.py | 8 | ||||
| -rw-r--r-- | tests/view_tests/regression_21530_urls.py | 5 | ||||
| -rw-r--r-- | tests/view_tests/tests/test_debug.py | 29 |
3 files changed, 42 insertions, 0 deletions
diff --git a/tests/view_tests/default_urls.py b/tests/view_tests/default_urls.py new file mode 100644 index 0000000000..511689ccb1 --- /dev/null +++ b/tests/view_tests/default_urls.py @@ -0,0 +1,8 @@ +from django.conf.urls import patterns, include, url + +from django.contrib import admin + +urlpatterns = patterns('', + # This is the same as in the default project template + url(r'^admin/', include(admin.site.urls)), +) diff --git a/tests/view_tests/regression_21530_urls.py b/tests/view_tests/regression_21530_urls.py new file mode 100644 index 0000000000..14248d872b --- /dev/null +++ b/tests/view_tests/regression_21530_urls.py @@ -0,0 +1,5 @@ +from django.conf.urls import patterns, url + +urlpatterns = patterns('', + url(r'^index/$', 'view_tests.views.index_page', name='index'), +) diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py index 7be5b43a96..1f84933261 100644 --- a/tests/view_tests/tests/test_debug.py +++ b/tests/view_tests/tests/test_debug.py @@ -139,6 +139,35 @@ class DebugViewTests(TestCase): """ self.assertRaises(TemplateDoesNotExist, self.client.get, '/render_no_template/') + @override_settings(ROOT_URLCONF='view_tests.default_urls') + def test_default_urlconf_template(self): + """ + Make sure that the default urlconf template is shown shown instead + of the technical 404 page, if the user has not altered their + url conf yet. + """ + response = self.client.get('/') + self.assertContains( + response, + "<h2>Congratulations on your first Django-powered page.</h2>" + ) + + @override_settings(ROOT_URLCONF='view_tests.regression_21530_urls') + def test_regression_21530(self): + """ + Regression test for bug #21530. + + If the admin app include is replaced with exactly one url + pattern, then the technical 404 template should be displayed. + + The bug here was that an AttributeError caused a 500 response. + """ + response = self.client.get('/') + self.assertContains( + response, + "Page not found <span>(404)</span>", + status_code=404 + ) class ExceptionReporterTests(TestCase): rf = RequestFactory() |
