vendredi 6 janvier 2017

Force ConnectionError with Django cache in Tests

I have code which handles a ConnectionError when Django cannot connect to the Cache, which I'd like to test.

I've hit an issue that without actually disabling the real cache, I can't simulate it within the tests.

I have tried using the Django settings override:

with self.settings(CACHES={'default': {'BACKEND': 'django.core.cache.backends.dummy.DummyCache'}}):

However the above only simulates a cache, and not that it isn't available.

Is there a way to do this?

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire