From 74b7a20fe6973a53923059795cb538d094c925d8 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Mon, 31 Jul 2017 18:30:18 -0400 Subject: [PATCH] Refs #5046 -- Tested the 'unicode hint' in the technical 500 debug view. --- tests/view_tests/tests/test_debug.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py index a89507269a..aa0a025eed 100644 --- a/tests/view_tests/tests/test_debug.py +++ b/tests/view_tests/tests/test_debug.py @@ -446,6 +446,18 @@ class ExceptionReporterTests(SimpleTestCase): self.assertEqual(len(html) // 1024 // 128, 0) # still fit in 128Kb self.assertIn('<trimmed %d bytes string>' % (large + repr_of_str_adds,), html) + def test_encoding_error(self): + """A UnicodeError displays a portion of the problematic string.""" + try: + 'abcdefghijklmnὀpqrstuwxyz'.encode('ascii') + except Exception: + exc_type, exc_value, tb = sys.exc_info() + reporter = ExceptionReporter(None, exc_type, exc_value, tb) + html = reporter.get_traceback_html() + self.assertIn('

Unicode error hint

', html) + self.assertIn('The string that could not be encoded/decoded was: ', html) + self.assertIn('jklmnὀpqrst', html) + def test_unfrozen_importlib(self): """ importlib is not a frozen app, but its loader thinks it's frozen which