Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[1.2.X] Migrated urlpatterns_reverse doctests. Thanks to Stephan Jaekel.

Backport of r13893 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@13914 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 2f480e088244e4fb81d3cf27d1ca7f533698a41a 1 parent 8425cde
@freakboy3742 freakboy3742 authored
Showing with 21 additions and 13 deletions.
  1. +21 −13 tests/regressiontests/urlpatterns_reverse/tests.py
View
34 tests/regressiontests/urlpatterns_reverse/tests.py
@@ -1,19 +1,6 @@
"""
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
-"""}
-
import unittest
from django.conf import settings
@@ -107,6 +94,27 @@
)
+class NoURLPatternsTests(TestCase):
+ urls = 'regressiontests.urlpatterns_reverse.no_urls'
+
+ def assertRaisesErrorWithMessage(self, error, message, callable,
+ *args, **kwargs):
+ self.assertRaises(error, callable, *args, **kwargs)
+ try:
+ callable(*args, **kwargs)
+ except error, e:
+ self.assertEqual(message, str(e))
+
+ def test_no_urls_exception(self):
+ """
+ RegexURLResolver should raise an exception when no urlpatterns exist.
+ """
+ resolver = RegexURLResolver(r'^$', self.urls)
+
+ self.assertRaisesErrorWithMessage(ImproperlyConfigured,
+ "The included urlconf regressiontests.urlpatterns_reverse.no_urls "\
+ "doesn't have any patterns in it", getattr, resolver, 'url_patterns')
+
class URLPatternReverse(TestCase):
urls = 'regressiontests.urlpatterns_reverse.urls'
Please sign in to comment.
Something went wrong with that request. Please try again.