summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/view_tests/tests/test_debug.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py
index 3fe89d9bf3..24fa593621 100644
--- a/tests/view_tests/tests/test_debug.py
+++ b/tests/view_tests/tests/test_debug.py
@@ -515,6 +515,33 @@ class ExceptionReporterTests(SimpleTestCase):
html = reporter.get_traceback_html()
self.assertInHTML('<td>items</td><td class="code"><pre>&#39;Oops&#39;</pre></td>', html)
+ def test_exception_fetching_user(self):
+ """
+ The error page can be rendered if the current user can't be retrieved
+ (such as when the database is unavailable).
+ """
+ class ExceptionUser(object):
+ def __str__(self):
+ raise Exception()
+
+ request = self.rf.get('/test_view/')
+ request.user = ExceptionUser()
+
+ try:
+ raise ValueError('Oops')
+ except ValueError:
+ exc_type, exc_value, tb = sys.exc_info()
+
+ reporter = ExceptionReporter(request, exc_type, exc_value, tb)
+ html = reporter.get_traceback_html()
+ self.assertIn('<h1>ValueError at /test_view/</h1>', html)
+ self.assertIn('<pre class="exception_value">Oops</pre>', html)
+ self.assertIn('<h3 id="user-info">USER</h3>', html)
+ self.assertIn('<p>[unable to retrieve the current user]</p>', html)
+
+ text = reporter.get_traceback_text()
+ self.assertIn('USER: [unable to retrieve the current user]', text)
+
class PlainTextReportTests(SimpleTestCase):
rf = RequestFactory()