diff options
| author | Nick Pope <nick.pope@flightdataservices.com> | 2019-04-05 14:38:35 +0200 |
|---|---|---|
| committer | Carlton Gibson <carlton.gibson@noumenal.es> | 2019-04-05 16:35:01 +0200 |
| commit | efb257a01764855a71051d5bcc7fd66c5ad6d210 (patch) | |
| tree | 16ce55154b0977b8b861092b12a17c447863af5a /tests | |
| parent | 9012033138fa41b573d3e4e3f0dfa8b94a4719c6 (diff) | |
Fixed #30324 -- Forced utf-8 encoding when loading the template for the technical 500 debug page.
Regression in 50b8493.
Related to ea542a9.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/view_tests/tests/test_debug.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py index a6e5275c9f..51b27bf361 100644 --- a/tests/view_tests/tests/test_debug.py +++ b/tests/view_tests/tests/test_debug.py @@ -7,6 +7,7 @@ import tempfile import threading from io import StringIO from pathlib import Path +from unittest import mock from django.core import mail from django.core.files.uploadedfile import SimpleUploadedFile @@ -20,7 +21,8 @@ from django.utils.functional import SimpleLazyObject from django.utils.safestring import mark_safe from django.views.debug import ( CLEANSED_SUBSTITUTE, CallableSettingWrapper, ExceptionReporter, - cleanse_setting, technical_500_response, + Path as DebugPath, cleanse_setting, default_urlconf, + technical_404_response, technical_500_response, ) from ..views import ( @@ -648,6 +650,20 @@ class ExceptionReporterTests(SimpleTestCase): text = reporter.get_traceback_text() self.assertIn('USER: [unable to retrieve the current user]', text) + def test_template_encoding(self): + """ + The templates are loaded directly, not via a template loader, and + should be opened as utf-8 charset as is the default specified on + template engines. + """ + reporter = ExceptionReporter(None, None, None, None) + with mock.patch.object(DebugPath, 'open') as m: + reporter.get_traceback_html() + m.assert_called_once_with(encoding='utf-8') + m.reset_mock() + reporter.get_traceback_text() + m.assert_called_once_with(encoding='utf-8') + class PlainTextReportTests(SimpleTestCase): rf = RequestFactory() |
