mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #14503 -- Unified multiple implementations of test cases assert* methods that verify a given exception is raised by a callable throughout the Django test suite.
Replaced them with a new assertRaisesMessage method of a new SimpleTestCase, a lightweight subclass of unittest.TestCase. Both are also available for usage in user tests. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16610 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -138,21 +138,13 @@ test_data = (
|
||||
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,
|
||||
self.assertRaisesMessage(ImproperlyConfigured,
|
||||
"The included urlconf regressiontests.urlpatterns_reverse.no_urls "\
|
||||
"doesn't have any patterns in it", getattr, resolver, 'url_patterns')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user