Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit 7d9de178e724573c1326ee2c2bf4f0b8b15b6c62 1 parent 2ef52d0
Adrian Holovaty adrianholovaty authored
16 django/core/handlers/base.py
View
@@ -72,13 +72,8 @@ def get_response(self, request):
try:
# Reset the urlconf for this thread.
urlresolvers.set_urlconf(None)
-
- # 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)
- resolver = urlresolvers.RegexURLResolver(r'^/', urlconf)
+ # Obtain a default resolver. It's needed early for handling 404's.
+ resolver = urlresolvers.RegexURLResolver(r'^/', None)
# Apply request middleware
for middleware_method in self._request_middleware:
@@ -86,6 +81,13 @@ def get_response(self, request):
if 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(
request.path_info)
6 tests/regressiontests/middleware_exceptions/tests.py
View
@@ -8,15 +8,13 @@ def process_request(self, request):
raise Exception('Exception')
class MiddlewareExceptionTest(TestCase):
- def __init__(self, *args, **kwargs):
- super(MiddlewareExceptionTest, self).__init__(*args, **kwargs)
+ def setUp(self):
self.exceptions = []
got_request_exception.connect(self._on_request_exception)
-
- def setUp(self):
self.client.handler.load_middleware()
def tearDown(self):
+ got_request_exception.disconnect(self._on_request_exception)
self.exceptions = []
def _on_request_exception(self, sender, request, **kwargs):
Please sign in to comment.
Something went wrong with that request. Please try again.