diff --git a/fakeredis/commands_mixins/_generic_mixin.py b/fakeredis/commands_mixins/_generic_mixin.py index 03eb957f..2e6bc4ed 100644 --- a/fakeredis/commands_mixins/_generic_mixin.py +++ b/fakeredis/commands_mixins/_generic_mixin.py @@ -1,6 +1,6 @@ import hashlib import pickle -from random import random +import random from fakeredis import _msgs as msgs from fakeredis._commands import command, Key, Int, DbIndex, BeforeAny, CommandItem, SortFloat diff --git a/pyproject.toml b/pyproject.toml index 3835ef6a..7290dfef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ name = "fakeredis" packages = [ { include = "fakeredis" }, ] -version = "1.10.1" +version = "1.10.2" description = "Fake implementation of redis API for testing purposes." readme = "README.md" keywords = ["redis", "rq", "django-rq", "rq-scheduler"] diff --git a/test/test_mixins/test_generic_mixin.py b/test/test_mixins/test_generic_mixin.py new file mode 100644 index 00000000..7abf280a --- /dev/null +++ b/test/test_mixins/test_generic_mixin.py @@ -0,0 +1,9 @@ +def test_randomkey_returns_none_on_empty_db(r): + assert r.randomkey() is None + + +def test_randomkey_returns_existing_key(r): + r.set("foo", 1) + r.set("bar", 2) + r.set("baz", 3) + assert r.randomkey().decode() in ("foo", "bar", "baz")