From 94d1d4a71b31647991e3a7617166f82a6eb1ccff Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Wed, 19 Feb 2020 20:32:23 -0800 Subject: [PATCH] Captured logging in DebugViewTests with assertLogs(). --- tests/view_tests/tests/test_debug.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py index 63a9142862..111a7f1f75 100644 --- a/tests/view_tests/tests/test_debug.py +++ b/tests/view_tests/tests/test_debug.py @@ -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)