TL;DR; How do you modify cache settings during testing? Specifically,
enable/disable (by making TIMEOUT zero or non-zero).

Full question:

I had some code that looked like this:

from django.core.cache import cache
data = cache.get(key, {})

etc.

Now it looks like this:

from django.core.cache import caches
data = caches["default"].get(key, {})

etc.

The problem is that I have tests that change the TIMEOUT cache setting and
then reload the
module, using *six.moves.reload_module*. After making the change, the
reload never works. The
timeout remains the same as it is in the settings.py file.

The reason for the change is that I've been asked to use another cache
(other than *default*) for the
caching for this section of the app. The Django docs say that "import
cache" is deprecated, and
the proper way to do it since 1.7 is to use caches. We're using Django 1.8.

The docs (
https://docs.djangoproject.com/en/1.8/topics/testing/tools/#overriding-settings)
say "We do not recommend altering the DATABASES
<https://docs.djangoproject.com/en/1.8/ref/settings/#std:setting-DATABASES>
setting.
Altering the CACHES
<https://docs.djangoproject.com/en/1.8/ref/settings/#std:setting-CACHES>
setting
is possible," but offers no details.

Has anyone found a solution for this?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAOzwKwFck7mCmJ1%3D9ARPjjGBZ%3DuHBMDVLn7C2mPzPTyQX%3DvLTg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to