From faee1ed2a2583ed3f7d4228501e0a10113843b10 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 20 Dec 2021 21:48:38 +0000 Subject: [PATCH] Test middleware not injecting when Content-Encoding is set Follow up to #1560. --- tests/test_integration.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_integration.py b/tests/test_integration.py index b76ebf875..702fa8141 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -96,6 +96,15 @@ def get_response(request): # check toolbar insertion before "" self.assertContains(response, "\n") + def test_middleware_no_injection_when_encoded(self): + def get_response(request): + response = HttpResponse("") + response["Content-Encoding"] = "something" + return response + + response = DebugToolbarMiddleware(get_response)(self.request) + self.assertEqual(response.content, b"") + def test_cache_page(self): # Clear the cache before testing the views. Other tests that use cached_view # may run earlier and cause fewer cache calls.