#33798: @cache_control test fails after upgrade to 4.0.5
-------------------------------------+-------------------------------------
Reporter: Matt | Owner: nobody
Hegarty |
Type: | Status: new
Uncategorized |
Component: | Version: 4.0
Uncategorized | Keywords: cache_control
Severity: Normal | decorator
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
This worked ok in 3.2.13 - fails after upgrade to 4.0.5
Test:
{{{
class FaviconTests(SimpleTestCase):
def test_get(self):
response = self.client.get("/favicon.ico")
self.assertEqual(response.status_code, HTTPStatus.OK)
self.assertEqual(response["Cache-Control"], "max-age=86400,
immutable, public")
self.assertEqual(response["Content-Type"], "image/png")
content = b"".join(response.streaming_content)
self.assertGreater(len(content), 0)
}}}
View:
{{{
from django.conf import settings
from django.http import FileResponse
from django.views.decorators.cache import cache_control
from django.views.generic.base import View
class FaviconView(View):
@cache_control(max_age=60 * 60 * 24, immutable=True, public=True)
def get(self, request, *args, **kwargs):
file = (
settings.BASE_DIR / settings.STATIC_ROOT / "img" / "favicon-
32x32.png"
).open("rb")
return FileResponse(file)
}}}
Error:
TypeError: cache_control didn't receive an HttpRequest. If you are
decorating a classmethod, be sure to use @method_decorator.
--
Ticket URL: <https://code.djangoproject.com/ticket/33798>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/010701818b4b927c-f65e7ed5-b99b-42c2-ab14-baee9f58be6d-000000%40eu-central-1.amazonses.com.