I'm using django.core.cache.backends.dummy.DummyCache
in my tests, however, there is one test which requires actual caching so I want to overwrite the CACHE setting for this one particular test. Where I want to test a view using the cache_page decorator.
To archive this I use the @override_settings
for my test like this: @override_settings(CACHES={'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}})
. This works fine if I only run this test. But now some other tests are failing. In the django docs
I found a warning which says:
Altering the CACHES setting is possible, but a bit tricky if you are using internals that make using of caching, like django.contrib.sessions. For example, you will have to reinitialize the session backend in a test that uses cached sessions and overrides CACHES.
So I assume I have to reinitialize the middleware stack somehow. But I'm not sure and get stuck at this point.
Aucun commentaire:
Enregistrer un commentaire