1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #29714 -- Allowed using ExceptionReporter subclass with AdminEmailHandler.

This commit is contained in:
Nasir Hussain
2019-02-24 20:10:14 +05:00
committed by Mariusz Felisiak
parent 3c6a4fdb6d
commit 25706d7285
5 changed files with 53 additions and 4 deletions

View File

@@ -16,6 +16,7 @@ from django.utils.log import (
DEFAULT_LOGGING, AdminEmailHandler, CallbackFilter, RequireDebugFalse,
RequireDebugTrue, ServerFormatter,
)
from django.views.debug import ExceptionReporter
from . import views
from .logconfig import MyEmailBackend
@@ -431,6 +432,20 @@ class AdminEmailHandlerTest(SimpleTestCase):
finally:
admin_email_handler.include_html = old_include_html
def test_default_exception_reporter_class(self):
admin_email_handler = self.get_admin_email_handler(self.logger)
self.assertEqual(admin_email_handler.reporter_class, ExceptionReporter)
@override_settings(ADMINS=[('A.N.Admin', 'admin@example.com')])
def test_custom_exception_reporter_is_used(self):
record = self.logger.makeRecord('name', logging.ERROR, 'function', 'lno', 'message', None, None)
record.request = self.request_factory.get('/')
handler = AdminEmailHandler(reporter_class='logging_tests.logconfig.CustomExceptionReporter')
handler.emit(record)
self.assertEqual(len(mail.outbox), 1)
msg = mail.outbox[0]
self.assertEqual(msg.body, 'message\n\ncustom traceback text')
class SettingsConfigTest(AdminScriptTestCase):
"""