diff options
| author | Tim Graham <timograham@gmail.com> | 2014-10-06 16:07:20 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-10-06 17:37:38 -0400 |
| commit | 96f022203a552fef19403c01b12fa6d30da560a0 (patch) | |
| tree | f5108ea1f361614cec4380e31f538a1069fe3cd7 /tests | |
| parent | c2508990cb53b52783ebb38dc0b5f0ab5d023c76 (diff) | |
[1.7.x] Fixed #23593 -- Fixed crash in AdminEmailHandler with non-ASCII characters in request.
Thanks edevil for the report and Simon Charette for review.
Backport of 9dff5ce7c7 from master
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/logging_tests/tests.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/logging_tests/tests.py b/tests/logging_tests/tests.py index 34ed24dc6a..d840225727 100644 --- a/tests/logging_tests/tests.py +++ b/tests/logging_tests/tests.py @@ -1,3 +1,4 @@ +# -*- coding:utf-8 -*- from __future__ import unicode_literals import logging @@ -319,6 +320,26 @@ class AdminEmailHandlerTest(TestCase): mail.mail_admins = orig_mail_admins admin_email_handler.email_backend = orig_email_backend + @override_settings( + ADMINS=(('whatever admin', 'admin@example.com'),), + ) + def test_emit_non_ascii(self): + """ + #23593 - AdminEmailHandler should allow Unicode characters in the + request. + """ + handler = self.get_admin_email_handler(self.logger) + record = self.logger.makeRecord('name', logging.ERROR, 'function', 'lno', 'message', None, None) + rf = RequestFactory() + url_path = '/ยบ' + record.request = rf.get(url_path) + handler.emit(record) + self.assertEqual(len(mail.outbox), 1) + msg = mail.outbox[0] + self.assertEqual(msg.to, ['admin@example.com']) + self.assertEqual(msg.subject, "[Django] ERROR (EXTERNAL IP): message") + self.assertIn("path:%s" % url_path, msg.body) + class SettingsConfigTest(AdminScriptTestCase): """ |
