[Django] #28094: Cache settings override does not work properly

34 views
Skip to first unread message

Django

unread,
Apr 18, 2017, 4:53:22 PM4/18/17
to django-...@googlegroups.com
#28094: Cache settings override does not work properly
---------------------------------------------+------------------------
Reporter: R3turnz | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 1.11
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------------+------------------------
The following should override the CACHES setting during tests:
{{{#!python
@method_decorator(cache_page(60 * 5), name='dispatch')
class IndexView(generic.ListView):

if ENABLE_CACHING:
CACHES = get_cache()
else:
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
}
}

@override_settings(CACHES={'default': {'BACKEND':
'django.core.cache.backends.dummy.DummyCache'}})
class IndexViewTests(TestCase):
}}}
The setting also seems to be correctly overriden, (django.conf.settings
contains dummy cache) but I encounter following problems:
* The context of the response is always None.
* Test which formerly passed now fail and view functions are not called.
All problems disappear when I disable caching **manually**!
This leads me to the assumption that the views are stilled cached.
The documentation says that overriding the cache should be possible and I
am not using sessions framwork.
I do not have enough knowledge of the architecture of django to do further
debugging.

--
Ticket URL: <https://code.djangoproject.com/ticket/28094>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 20, 2017, 8:26:24 AM4/20/17
to django-...@googlegroups.com
#28094: Cache settings override does not work properly
-----------------------------------+--------------------------------------

Reporter: R3turnz | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 1.11
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

Comment (by Tim Graham):

I suspect this is not a bug but that you'll have to reinitialize the
class-based view after overriding the `CACHES` setting since it's already
been initialized with the original settings values.

If that's correct, perhaps
[https://github.com/django/django/blob/43b4a1618ed85151494d68778a1bb6304ce1cb79/docs/topics/testing/tools.txt#L1265-L1270
the documentation] could be clarified.

--
Ticket URL: <https://code.djangoproject.com/ticket/28094#comment:1>

Django

unread,
Apr 21, 2017, 3:42:42 AM4/21/17
to django-...@googlegroups.com
#28094: Cache settings override does not work properly
-----------------------------------+--------------------------------------

Reporter: R3turnz | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 1.11
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

Comment (by R3turnz):

I agree with you that this could be the problem, but how do reinitialize
the settings?

--
Ticket URL: <https://code.djangoproject.com/ticket/28094#comment:2>

Django

unread,
May 31, 2017, 11:20:46 AM5/31/17
to django-...@googlegroups.com
#28094: Document how @override_settings(CACHES=...) can work with class-based views
-------------------------------------+-------------------------------------
Reporter: R3turnz | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: 1.11
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* type: Bug => Cleanup/optimization
* component: Testing framework => Documentation


Comment:

I'm not sure if there's an elegant way for this to work.

--
Ticket URL: <https://code.djangoproject.com/ticket/28094#comment:3>

Django

unread,
May 31, 2017, 11:21:00 AM5/31/17
to django-...@googlegroups.com
#28094: Document how @override_settings(CACHES=...) can work with class-based views
--------------------------------------+------------------------------------
Reporter: R3turnz | Owner: nobody
Type: Cleanup/optimization | Status: new

Component: Documentation | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/28094#comment:4>

Django

unread,
Nov 13, 2018, 11:26:12 AM11/13/18
to django-...@googlegroups.com
#28094: Document how @override_settings(CACHES=...) can work with class-based views
--------------------------------------+------------------------------------
Reporter: R3turnz | Owner: nobody

Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Kevin Graves):

* cc: Kevin Graves (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/28094#comment:5>

Reply all
Reply to author
Forward
0 new messages