Reset cache between tests

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

  1. MintCache by gfranxman 5 years, 1 month ago
  2. decorators for creating paramaterized decorators and easy monkeypatching by fish2000 2 years, 4 months ago
  3. Use crypt instead of sha1 as password hash algorithm by akaihola 4 years, 9 months ago
  4. Scoped Cache Compatible with Django Caching Helpers by axiak 4 years, 2 months ago
  5. django-noserun for testing by mjt 3 years, 2 months ago

Comments

(Forgotten your password?)