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. decorators for creating paramaterized decorators and easy monkeypatching by fish2000 4 years, 2 months ago
  2. django-noserun for testing by mjt 5 years, 1 month ago
  3. Scoped Cache Compatible with Django Caching Helpers by axiak 6 years, 1 month ago
  4. Test and Restart Memcached Server by Digitalxero 5 years, 6 months ago
  5. Built-in Slugify with filtering. by jcrawford 5 years ago

Comments

(Forgotten your password?)