Skip to content

Commit

Permalink
Fix/v1.10.1/random import generic commands mixin (#136)
Browse files Browse the repository at this point in the history
* Fix import used in GenericCommandsMixin.randomkey
* Bump pyproject version to 1.10.2
  • Loading branch information
mudetz authored Mar 31, 2023
1 parent 7d79727 commit 7a83b89
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion fakeredis/commands_mixins/_generic_mixin.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
9 changes: 9 additions & 0 deletions test/test_mixins/test_generic_mixin.py
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit 7a83b89

Please sign in to comment.