mirror of https://github.com/django/django.git
Fixed #6094 again -- fixed broken unit tests. Thanks, isagalaev
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12186 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
2ef52d0ce2
commit
7d9de178e7
|
@ -72,13 +72,8 @@ class BaseHandler(object):
|
||||||
try:
|
try:
|
||||||
# Reset the urlconf for this thread.
|
# Reset the urlconf for this thread.
|
||||||
urlresolvers.set_urlconf(None)
|
urlresolvers.set_urlconf(None)
|
||||||
|
# Obtain a default resolver. It's needed early for handling 404's.
|
||||||
# Get urlconf from request object, if available. Otherwise use default.
|
resolver = urlresolvers.RegexURLResolver(r'^/', None)
|
||||||
urlconf = getattr(request, "urlconf", settings.ROOT_URLCONF)
|
|
||||||
|
|
||||||
# Set the urlconf for this thread to the one specified above.
|
|
||||||
urlresolvers.set_urlconf(urlconf)
|
|
||||||
resolver = urlresolvers.RegexURLResolver(r'^/', urlconf)
|
|
||||||
|
|
||||||
# Apply request middleware
|
# Apply request middleware
|
||||||
for middleware_method in self._request_middleware:
|
for middleware_method in self._request_middleware:
|
||||||
|
@ -86,6 +81,13 @@ class BaseHandler(object):
|
||||||
if response:
|
if response:
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
# Get urlconf from request object, if available. Otherwise use default.
|
||||||
|
urlconf = getattr(request, "urlconf", settings.ROOT_URLCONF)
|
||||||
|
# Set the urlconf for this thread to the one specified above.
|
||||||
|
urlresolvers.set_urlconf(urlconf)
|
||||||
|
# Reset the resolver with a possibly new urlconf
|
||||||
|
resolver = urlresolvers.RegexURLResolver(r'^/', urlconf)
|
||||||
|
|
||||||
callback, callback_args, callback_kwargs = resolver.resolve(
|
callback, callback_args, callback_kwargs = resolver.resolve(
|
||||||
request.path_info)
|
request.path_info)
|
||||||
|
|
||||||
|
|
|
@ -8,15 +8,13 @@ class RequestMiddleware(object):
|
||||||
raise Exception('Exception')
|
raise Exception('Exception')
|
||||||
|
|
||||||
class MiddlewareExceptionTest(TestCase):
|
class MiddlewareExceptionTest(TestCase):
|
||||||
def __init__(self, *args, **kwargs):
|
def setUp(self):
|
||||||
super(MiddlewareExceptionTest, self).__init__(*args, **kwargs)
|
|
||||||
self.exceptions = []
|
self.exceptions = []
|
||||||
got_request_exception.connect(self._on_request_exception)
|
got_request_exception.connect(self._on_request_exception)
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
self.client.handler.load_middleware()
|
self.client.handler.load_middleware()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
got_request_exception.disconnect(self._on_request_exception)
|
||||||
self.exceptions = []
|
self.exceptions = []
|
||||||
|
|
||||||
def _on_request_exception(self, sender, request, **kwargs):
|
def _on_request_exception(self, sender, request, **kwargs):
|
||||||
|
|
Loading…
Reference in New Issue