
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Easier use fakeredis in Django.
pip install django-fakeredis
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 and can debug with MONITOR command in redis
NOFAKE_REDIS=1 python manage.py test
Before you use django_fakeredis
, your tests 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:
@FakeRedis("yourpath.get_redis_connection")
def test_sth():
...
from django_fakeredis import FakeRedis
@FakeRedis("yourpath.get_redis_connection")
def test_foo():
...
from django_fakeredis import FakeRedis
with FakeRedis("yourpath.get_redis_connection"):
foo()
from django_fakeredis import FakeRedis
with FakeRedis("yourpath.cache"):
foo()
django.core.cache.cache
with fakeredis, django-fakeredis do nothing but just override CACHE settings into Local-Memory for using the internal cast. So there are two mocked redis instance for django.cache and get_redis_connection .If you want to use more redis commands, such as: sets, list..., you may need use django_redis, and cast the result by hand.
django.cache:
from django.core.cache import cache
cache.set("key", 2)
assert cache.get("key") == 2
you have to cast by hand, when using fakeredis or django_redis directly, you have to cast by hand:
import fakeredis
con = fakeredis.FakeStrictRedis()
con.set("key", 2)
assert con.get("key").decode('utf8') == "2"
FAQs
Easier to use fakeredis in Django.
We found that django-fakeredis demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.