diff --git a/django/contrib/messages/tests/base.py b/django/contrib/messages/tests/base.py
index 8d04532..789faf4 100644
a
|
b
|
class BaseTest(TestCase):
|
56 | 56 | |
57 | 57 | def setUp(self): |
58 | 58 | self.settings_override = override_settings_tags( |
59 | | TEMPLATE_DIRS = (), |
| 59 | TEMPLATE_LOADERS = (), |
60 | 60 | MESSAGE_TAGS = '', |
61 | 61 | MESSAGE_STORAGE = '%s.%s' % (self.storage_class.__module__, |
62 | 62 | self.storage_class.__name__), |
63 | 63 | ) |
64 | 64 | self.settings_override.enable() |
| 65 | self.reset_handlers_state() |
65 | 66 | |
66 | 67 | def tearDown(self): |
67 | 68 | self.settings_override.disable() |
| 69 | self.restore_handlers_state() |
68 | 70 | |
69 | 71 | def get_request(self): |
70 | 72 | return http.HttpRequest() |
diff --git a/django/test/testcases.py b/django/test/testcases.py
index ee22ac2..d8a882a 100644
a
|
b
|
from functools import wraps
|
6 | 6 | from urlparse import urlsplit, urlunsplit |
7 | 7 | from xml.dom.minidom import parseString, Node |
8 | 8 | |
9 | | from django.conf import settings |
| 9 | from django.conf import settings, urls as urlhandlers |
10 | 10 | from django.core import mail |
11 | 11 | from django.core.exceptions import ValidationError |
12 | 12 | from django.core.management import call_command |
… |
… |
class SimpleTestCase(ut2.TestCase):
|
262 | 262 | """ |
263 | 263 | restore_warnings_state(self._warnings_state) |
264 | 264 | |
| 265 | def reset_handlers_state(self): |
| 266 | """ |
| 267 | Save url handlers state and reset to default value |
| 268 | """ |
| 269 | self._old_url_handlers = ( |
| 270 | urlhandlers.handler403, |
| 271 | urlhandlers.handler404, |
| 272 | urlhandlers.handler500 |
| 273 | ) |
| 274 | handler403 = 'django.views.defaults.permission_denied' |
| 275 | handler404 = 'django.views.defaults.page_not_found' |
| 276 | handler500 = 'django.views.defaults.server_error' |
| 277 | |
| 278 | def restore_handlers_state(self): |
| 279 | """ |
| 280 | Restore handlers to the state before reset_handlers_state() |
| 281 | """ |
| 282 | handler403, handler404, handler500 = self._old_url_handlers |
| 283 | |
265 | 284 | def settings(self, **kwargs): |
266 | 285 | """ |
267 | 286 | A context manager that temporarily sets a setting and reverts |