summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBas Peschier <basp@fabrique.nl>2015-03-07 13:18:04 +0100
committerTim Graham <timograham@gmail.com>2015-03-09 20:30:01 -0400
commit756cee46d25a52108fd7190f787a7e636962df5d (patch)
tree534e871dfe139c384c1f043d3357360f3c3cd620 /tests
parent578ac17f814f21648484a1d846413398e92f8808 (diff)
Fixed #24455 -- Fixed crash in debug view with lazy objects
Diffstat (limited to 'tests')
-rw-r--r--tests/view_tests/tests/test_debug.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py
index 30dd3a90ad..51f86f225f 100644
--- a/tests/view_tests/tests/test_debug.py
+++ b/tests/view_tests/tests/test_debug.py
@@ -18,6 +18,7 @@ from django.template.base import TemplateDoesNotExist
from django.test import RequestFactory, TestCase, override_settings
from django.utils import six
from django.utils.encoding import force_bytes, force_text
+from django.utils.functional import SimpleLazyObject
from django.views.debug import CallableSettingWrapper, ExceptionReporter
from .. import BrokenException, except_args
@@ -380,6 +381,36 @@ class ExceptionReporterTests(TestCase):
html = reporter.get_traceback_html()
self.assertIn('<h1>ImportError at /test_view/</h1>', html)
+ def test_ignore_traceback_evaluation_exceptions(self):
+ """
+ Don't trip over exceptions generated by crafted objects when
+ evaluating them while cleansing (#24455).
+ """
+ class BrokenEvaluation(Exception):
+ pass
+
+ def broken_setup():
+ raise BrokenEvaluation
+
+ request = self.rf.get('/test_view/')
+ broken_lazy = SimpleLazyObject(broken_setup)
+ try:
+ bool(broken_lazy)
+ except BrokenEvaluation:
+ exc_type, exc_value, tb = sys.exc_info()
+
+ reporter = ExceptionReporter(request, exc_type, exc_value, tb)
+ try:
+ html = reporter.get_traceback_html()
+ except BrokenEvaluation:
+ self.fail("Broken evaluation in traceback is not caught.")
+
+ self.assertIn(
+ "BrokenEvaluation",
+ html,
+ "Evaluation exception reason not mentioned in traceback"
+ )
+
class PlainTextReportTests(TestCase):
rf = RequestFactory()