Ticket #12594: 12594.patch
File 12594.patch, 3.0 KB (added by , 15 years ago) |
---|
-
django/core/handlers/base.py
diff --git a/django/core/handlers/base.py b/django/core/handlers/base.py index a9bb058..d09f833 100644
a b class BaseHandler(object): 174 174 request_repr = "Request repr() unavailable" 175 175 message = "%s\n\n%s" % (self._get_traceback(exc_info), request_repr) 176 176 mail_admins(subject, message, fail_silently=True) 177 # If Http500 handler is not installed, re-raise last exception 178 if resolver.urlconf_module is None: 179 raise exc_info[1], None, exc_info[2] 177 180 # Return an HttpResponse that displays a friendly error message. 178 181 callback, param_dict = resolver.resolve500() 179 182 return callback(request, **param_dict) -
tests/regressiontests/urlpatterns_reverse/tests.py
diff --git a/tests/regressiontests/urlpatterns_reverse/tests.py b/tests/regressiontests/urlpatterns_reverse/tests.py index d5f3ec9..52a00f5 100644
a b ImproperlyConfigured: The included urlconf regressiontests.urlpatterns_reverse.n 17 17 import unittest 18 18 19 19 from django.conf import settings 20 from django.core.exceptions import ImproperlyConfigured 20 21 from django.core.urlresolvers import reverse, resolve, NoReverseMatch, Resolver404 21 22 from django.http import HttpResponseRedirect, HttpResponsePermanentRedirect 22 23 from django.shortcuts import redirect … … class ErrorHandlerResolutionTests(TestCase): 303 304 handler = (empty_view, {}) 304 305 self.assertEqual(self.callable_resolver.resolve404(), handler) 305 306 self.assertEqual(self.callable_resolver.resolve500(), handler) 307 308 309 class NoRootUrlConfTests(TestCase): 310 """Tests for handler404 and handler500 if urlconf is None""" 311 urls = None 312 313 def test_no_handler_exception(self): 314 self.assertRaises(ImproperlyConfigured, self.client.get, '/test_client_regress/no_template_view/') 315 316 class ResolverIsNoneResolutionTests(TestCase): 317 """Tests that handler404 and handler500 are properly raised if urlconf is None""" 318 319 urls = None 320 321 def setUp(self): 322 from django.core.urlresolvers import RegexURLResolver 323 urlconf = 'regressiontests.urlpatterns_reverse.urls_error_handlers' 324 self.normal_resolver = RegexURLResolver(r'^$', urlconf) 325 self.empty_resolver = RegexURLResolver(r'^$', None) 326 327 def test_handler_exceptions(self): 328 from views import empty_view 329 handler = (empty_view, {}) 330 331 self.assertTrue(self.normal_resolver.urlconf_module is not None) 332 self.assertTrue(self.empty_resolver.urlconf_module is None) 333 334 self.assertEqual(self.normal_resolver.resolve404(), handler) 335 self.assertEqual(self.normal_resolver.resolve500(), handler) 336 337 #raises "AttributeError: 'NoneType' object has no attribute 'handler404'" 338 self.assertRaises(AttributeError, self.empty_resolver.resolve404) 339 #raises "AttributeError: 'NoneType' object has no attribute 'handler500'" 340 self.assertRaises(AttributeError, self.empty_resolver.resolve500)