Captured logging in DebugViewTests with assertLogs().

This commit is contained in:
Jon Dufresne 2020-02-19 20:32:23 -08:00 committed by Carlton Gibson
parent b7795d7673
commit 94d1d4a71b
1 changed files with 4 additions and 2 deletions

View File

@ -250,12 +250,14 @@ class DebugViewTests(SimpleTestCase):
self.assertContains(response, 'Page not found', status_code=404)
def test_exception_reporter_from_request(self):
response = self.client.get('/custom_reporter_class_view/')
with self.assertLogs('django.request', 'ERROR'):
response = self.client.get('/custom_reporter_class_view/')
self.assertContains(response, 'custom traceback text', status_code=500)
@override_settings(DEFAULT_EXCEPTION_REPORTER='view_tests.views.CustomExceptionReporter')
def test_exception_reporter_from_settings(self):
response = self.client.get('/raises500/')
with self.assertLogs('django.request', 'ERROR'):
response = self.client.get('/raises500/')
self.assertContains(response, 'custom traceback text', status_code=500)