From 35c7fe8334621fe5f9f6e96e46cea369e620cae0 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Wed, 11 Mar 2020 12:13:15 +0100 Subject: [PATCH] Completed test coverage for BaseHandler.process_exception_by_middleware(). --- tests/middleware_exceptions/tests.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/middleware_exceptions/tests.py b/tests/middleware_exceptions/tests.py index 984e132522..bd8794ded3 100644 --- a/tests/middleware_exceptions/tests.py +++ b/tests/middleware_exceptions/tests.py @@ -86,6 +86,15 @@ class MiddlewareTests(SimpleTestCase): self.assertEqual(mw.log, []) self.assertEqual(response.content, b'Exception caught') + @override_settings(MIDDLEWARE=[ + 'middleware_exceptions.middleware.ProcessExceptionMiddleware', + 'middleware_exceptions.middleware.ProcessExceptionLogMiddleware', + ]) + def test_response_from_process_exception_when_return_response(self): + response = self.client.get('/middleware_exceptions/error/') + self.assertEqual(mw.log, ['process-exception']) + self.assertEqual(response.content, b'Exception caught') + @override_settings(MIDDLEWARE=[ 'middleware_exceptions.middleware.LogMiddleware', 'middleware_exceptions.middleware.NotFoundMiddleware',