from django.test import TestCase from django.core.cache import cache from django.conf import settings class MyTests(TestCase): def tearDown(self): assert settings.CACHE_BACKEND == 'locmem:///' [cache.delete(key) for key in cache._cache.keys()]