1 2 3 4 5 6 7 8 | 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()]
|
More like this
- Non-pickling locmem (in-process memory) cache backend by akaihola 2 years, 2 months ago
- "Zoom in" on rendered HTML that the test client returns by peterbe 4 years, 1 month ago
- nginx x-accel-redirect protection of static files by sean 5 years, 5 months ago
- TestCase helpers by pbx 6 years, 2 months ago
- Extend simplejson to understand closures, functors, generators and iterators by ElfSternberg 4 years ago
Comments
I think you can just use
cache.clear()instead of looping through the keys.See also my blog post Changing Django cache backend between test cases and its comments for ideas about controlling caching in test suites.
#