summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJames Bennett <james@b-list.org>2014-07-26 14:39:14 +0200
committerJames Bennett <james@b-list.org>2014-07-26 14:39:14 +0200
commit63058786882f6a32649a0fdafae9cb425c95cd4e (patch)
treebc88f57d67aa0614171a478b5e13b1549c95187e /tests
parent6eed751162f10a3e93f4fa7c1eed2c43b70bb0ca (diff)
parentd0889863de50d65659f56f0b9ea0672a8b6482a1 (diff)
Merge pull request #2967 from hirokiky/fix23070
Fixed #23070 -- not to break the debug page by callable setting with __slots__
Diffstat (limited to 'tests')
-rw-r--r--tests/view_tests/tests/test_debug.py32
1 files changed, 31 insertions, 1 deletions
diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py
index 7d800ae591..3d51da9f94 100644
--- a/tests/view_tests/tests/test_debug.py
+++ b/tests/view_tests/tests/test_debug.py
@@ -20,7 +20,7 @@ from django.test import TestCase, RequestFactory, override_settings
from django.test.utils import override_with_test_loader
from django.utils.encoding import force_text, force_bytes
from django.utils import six
-from django.views.debug import ExceptionReporter
+from django.views.debug import CallableSettingWrapper, ExceptionReporter
from .. import BrokenException, except_args
from ..views import (sensitive_view, non_sensitive_view, paranoid_view,
@@ -29,6 +29,21 @@ from ..views import (sensitive_view, non_sensitive_view, paranoid_view,
multivalue_dict_key_error)
+class CallableSettingWrapperTests(TestCase):
+ """ Unittests for CallableSettingWrapper
+ """
+ def test_repr(self):
+ class WrappedCallable(object):
+ def __repr__(self):
+ return "repr from the wrapped callable"
+
+ def __call__(self):
+ pass
+
+ actual = repr(CallableSettingWrapper(WrappedCallable()))
+ self.assertEqual(actual, "repr from the wrapped callable")
+
+
@override_settings(DEBUG=True, TEMPLATE_DEBUG=True,
ROOT_URLCONF="view_tests.urls")
class DebugViewTests(TestCase):
@@ -660,6 +675,21 @@ class ExceptionReporterFilterTests(TestCase, ExceptionReportTestMixin):
response = self.client.get('/raises500/')
self.assertNotContains(response, "This should not be displayed", status_code=500)
+ def test_callable_settings_forbidding_to_set_attributes(self):
+ """
+ Callable settings which forbid to set attributes should not break
+ the debug page (#23070).
+ """
+ class CallableSettingWithSlots(object):
+ __slots__ = []
+
+ def __call__(self):
+ return "This should not be displayed"
+
+ with self.settings(DEBUG=True, WITH_SLOTS=CallableSettingWithSlots()):
+ response = self.client.get('/raises500/')
+ self.assertNotContains(response, "This should not be displayed", status_code=500)
+
def test_dict_setting_with_non_str_key(self):
"""
A dict setting containing a non-string key should not break the