Skip to main content

More easier to use fakeredis in django.

Project description


More easier to use fakeredis in django.


pip install django-fakeredis

Why use it?

I have experienced many times to find bugs which is caused by mutiple fakeredis instances in tests. We just want to use fakerredis like redis with one redis-server and different connections.


  • One fakeredis server with mutiple connections for tests like the way of using redis.
  • Combine override settings to DummyCACHE and fake get_redis_connection
  • To disable the fake action with passing env: "NOFAKE_REDIS=1" NOFAKE_REDIS=1 python test

Before you use django_fakeredis, your everty test code maybe like that:

server = fakeredis.FakeServer()
@override_settings(CACHES={"default": {"BACKEND": "django.core.cache.backends.dummy.DummyCache" }})
@patch('foo.get_redis_connection', fakeredis.FakeRedis(server=server)
def test_sth():

Now your can just:

def test_sth():


from django_fakeredis.fakeredis import FakeRedis
def test_foo():
from django_fakeredis.fakeredis import FakeRedis
with FakeRedis("yourpath.get_redis_connection"):

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-fakeredis, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size django_fakeredis-0.0.1-py3-none-any.whl (3.7 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page