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 4 years, 10 months ago
  2. decorators for creating paramaterized decorators and easy monkeypatching by fish2000 2 years ago
  3. Use crypt instead of sha1 as password hash algorithm by akaihola 4 years, 5 months ago
  4. Scoped Cache Compatible with Django Caching Helpers by axiak 3 years, 11 months ago
  5. django-noserun for testing by mjt 2 years, 10 months ago

Comments

(Forgotten your password?)