Skip to content

Instantly share code, notes, and snippets.

@zsoldosp
Created September 15, 2016 09:39
Show Gist options
  • Save zsoldosp/7a77f3f5ff21d60db0cd2bd4285f00c8 to your computer and use it in GitHub Desktop.
Save zsoldosp/7a77f3f5ff21d60db0cd2bd4285f00c8 to your computer and use it in GitHub Desktop.
import pytest
from django.core.cache import caches
@pytest.fixture()
def django_caches():
yield caches
# finalizer
for cache in caches.all():
cache.clear()
@pytest.mark.parametrize('i', [1, 2])
def test_caches_fixture_provides_an_empty_cache(django_caches, i):
key = 'foo'
for cache in django_caches.all():
assert key not in cache
cache.set(key=key, value=i)
assert key in cache
assert cache.get(key) == i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment