Nov. 12, 2017, 2:38 a.m.
How to disable cache during django tests
usually we don't want cache working while on tests
I do like this, in settings.py :
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': 'unique-snowflake',
},
}
TEST_CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
}
}
then in the tests, being in before a class or function, do this :
@override_settings(CACHES=settings.TEST_CACHES)
def function(........):
do something