Code

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

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

Patch fixing broken tests

Line 
1=== modified file 'django/core/handlers/base.py'
2--- django/core/handlers/base.py        2010-01-10 17:35:01 +0000
3+++ django/core/handlers/base.py        2010-01-10 18:23:48 +0000
4@@ -72,20 +72,22 @@
5             try:
6                 # Reset the urlconf for this thread.
7                 urlresolvers.set_urlconf(None)
8+                # Obtain a default resolver. It's needed early for handling 404's.
9+                resolver = urlresolvers.RegexURLResolver(r'^/', None)
10+
11+                # Apply request middleware
12+                for middleware_method in self._request_middleware:
13+                    response = middleware_method(request)
14+                    if response:
15+                        return response
16 
17                 # Get urlconf from request object, if available.  Otherwise use default.
18                 urlconf = getattr(request, "urlconf", settings.ROOT_URLCONF)
19-
20                 # Set the urlconf for this thread to the one specified above.
21                 urlresolvers.set_urlconf(urlconf)
22+                # Reset the resolver with a possibly new urlconf
23                 resolver = urlresolvers.RegexURLResolver(r'^/', urlconf)
24 
25-                # Apply request middleware
26-                for middleware_method in self._request_middleware:
27-                    response = middleware_method(request)
28-                    if response:
29-                        return response
30-
31                 callback, callback_args, callback_kwargs = resolver.resolve(
32                         request.path_info)
33 
34
35=== modified file 'tests/regressiontests/middleware_exceptions/tests.py'
36--- tests/regressiontests/middleware_exceptions/tests.py        2010-01-10 17:35:01 +0000
37+++ tests/regressiontests/middleware_exceptions/tests.py        2010-01-10 18:43:01 +0000
38@@ -8,15 +8,13 @@
39         raise Exception('Exception')
40 
41 class MiddlewareExceptionTest(TestCase):
42-    def __init__(self, *args, **kwargs):
43-        super(MiddlewareExceptionTest, self).__init__(*args, **kwargs)
44+    def setUp(self):
45         self.exceptions = []
46         got_request_exception.connect(self._on_request_exception)
47-
48-    def setUp(self):
49         self.client.handler.load_middleware()
50 
51     def tearDown(self):
52+        got_request_exception.disconnect(self._on_request_exception)
53         self.exceptions = []
54 
55     def _on_request_exception(self, sender, request, **kwargs):
56