Code

Ticket #16507: 16507.4.diff

File 16507.4.diff, 1.3 KB (added by claudep, 3 years ago)

Prevent any custom handler500 or 500.html template

Line 
1diff --git a/django/contrib/messages/tests/base.py b/django/contrib/messages/tests/base.py
2index 8d04532..8c4df96 100644
3--- a/django/contrib/messages/tests/base.py
4+++ b/django/contrib/messages/tests/base.py
5@@ -1,5 +1,5 @@
6 from django import http
7-from django.conf import settings
8+from django.conf import settings, urls as urlhandlers
9 from django.contrib.messages import constants, utils, get_level, set_level
10 from django.contrib.messages.api import MessageFailure
11 from django.contrib.messages.storage import default_storage, base
12@@ -56,15 +56,18 @@ class BaseTest(TestCase):
13 
14     def setUp(self):
15         self.settings_override = override_settings_tags(
16-            TEMPLATE_DIRS   = (),
17+            TEMPLATE_LOADERS = (),
18             MESSAGE_TAGS    = '',
19             MESSAGE_STORAGE = '%s.%s' % (self.storage_class.__module__,
20                                          self.storage_class.__name__),
21         )
22         self.settings_override.enable()
23+        self.old_handler500 = urlhandlers.handler500
24+        urlhandlers.handler500 = 'django.views.defaults.server_error'
25 
26     def tearDown(self):
27         self.settings_override.disable()
28+        urlhandlers.handler500 = self.old_handler500
29 
30     def get_request(self):
31         return http.HttpRequest()