Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #10065 -- Corrected an error message when an empty urlpattern o…

…bject is provided. Thanks to Matthew Flanagan for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10385 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit ff166a3cdce99e93c97a19781b17d60e67d70f99 1 parent 2b1934f
@freakboy3742 freakboy3742 authored
View
2  django/core/urlresolvers.py
@@ -209,7 +209,7 @@ def _get_url_patterns(self):
try:
iter(patterns)
except TypeError:
- raise ImproperlyConfigured("The included urlconf %s doesn't have any"
+ raise ImproperlyConfigured("The included urlconf %s doesn't have any "
"patterns in it" % self.urlconf_name)
return patterns
url_patterns = property(_get_url_patterns)
View
2  tests/regressiontests/urlpatterns_reverse/no_urls.py
@@ -0,0 +1,2 @@
+#from django.conf.urls.defaults import *
+
View
23 tests/regressiontests/urlpatterns_reverse/tests.py
@@ -1,6 +1,19 @@
"""
Unit tests for reverse URL lookups.
"""
+__test__ = {'API_TESTS': """
+
+RegexURLResolver should raise an exception when no urlpatterns exist.
+
+>>> from django.core.urlresolvers import RegexURLResolver
+>>> no_urls = 'regressiontests.urlpatterns_reverse.no_urls'
+>>> resolver = RegexURLResolver(r'^$', no_urls)
+>>> resolver.url_patterns
+Traceback (most recent call last):
+...
+ImproperlyConfigured: The included urlconf regressiontests.urlpatterns_reverse.no_urls doesn't have any patterns in it
+"""}
+
from django.core.urlresolvers import reverse, NoReverseMatch
from django.http import HttpResponseRedirect, HttpResponsePermanentRedirect
@@ -101,21 +114,21 @@ def test_urlpattern_reverse(self):
class ReverseShortcutTests(TestCase):
urls = 'regressiontests.urlpatterns_reverse.urls'
-
+
def test_redirect_to_object(self):
# We don't really need a model; just something with a get_absolute_url
class FakeObj(object):
def get_absolute_url(self):
return "/hi-there/"
-
+
res = redirect(FakeObj())
self.assert_(isinstance(res, HttpResponseRedirect))
self.assertEqual(res['Location'], '/hi-there/')
-
+
res = redirect(FakeObj(), permanent=True)
self.assert_(isinstance(res, HttpResponsePermanentRedirect))
self.assertEqual(res['Location'], '/hi-there/')
-
+
def test_redirect_to_view_name(self):
res = redirect('hardcoded2')
self.assertEqual(res['Location'], '/hardcoded/doc.pdf')
@@ -124,7 +137,7 @@ def test_redirect_to_view_name(self):
res = redirect('headlines', year='2008', month='02', day='17')
self.assertEqual(res['Location'], '/headlines/2008.02.17/')
self.assertRaises(NoReverseMatch, redirect, 'not-a-view')
-
+
def test_redirect_to_url(self):
res = redirect('/foo/')
self.assertEqual(res['Location'], '/foo/')
Please sign in to comment.
Something went wrong with that request. Please try again.