Ticket #6094: 6094.fix-broken-test.diff

File 6094.fix-broken-test.diff, 2.3 KB (added by isagalaev, 6 years ago)

Patch fixing broken tests

  • django/core/handlers/base.py

    === modified file 'django/core/handlers/base.py'
     
    7272            try:
    7373                # Reset the urlconf for this thread.
    7474                urlresolvers.set_urlconf(None)
     75                # Obtain a default resolver. It's needed early for handling 404's.
     76                resolver = urlresolvers.RegexURLResolver(r'^/', None)
     77
     78                # Apply request middleware
     79                for middleware_method in self._request_middleware:
     80                    response = middleware_method(request)
     81                    if response:
     82                        return response
    7583
    7684                # Get urlconf from request object, if available.  Otherwise use default.
    7785                urlconf = getattr(request, "urlconf", settings.ROOT_URLCONF)
    78 
    7986                # Set the urlconf for this thread to the one specified above.
    8087                urlresolvers.set_urlconf(urlconf)
     88                # Reset the resolver with a possibly new urlconf
    8189                resolver = urlresolvers.RegexURLResolver(r'^/', urlconf)
    8290
    83                 # Apply request middleware
    84                 for middleware_method in self._request_middleware:
    85                     response = middleware_method(request)
    86                     if response:
    87                         return response
    88 
    8991                callback, callback_args, callback_kwargs = resolver.resolve(
    9092                        request.path_info)
    9193
  • tests/regressiontests/middleware_exceptions/tests.py

    === modified file 'tests/regressiontests/middleware_exceptions/tests.py'
     
    88        raise Exception('Exception')
    99
    1010class MiddlewareExceptionTest(TestCase):
    11     def __init__(self, *args, **kwargs):
    12         super(MiddlewareExceptionTest, self).__init__(*args, **kwargs)
     11    def setUp(self):
    1312        self.exceptions = []
    1413        got_request_exception.connect(self._on_request_exception)
    15 
    16     def setUp(self):
    1714        self.client.handler.load_middleware()
    1815
    1916    def tearDown(self):
     17        got_request_exception.disconnect(self._on_request_exception)
    2018        self.exceptions = []
    2119
    2220    def _on_request_exception(self, sender, request, **kwargs):
Back to Top