diff options
Diffstat (limited to 'tests/test_commands.py')
-rw-r--r-- | tests/test_commands.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/test_commands.py b/tests/test_commands.py index 9884035..27117e3 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -895,6 +895,19 @@ class TestRedisCommands: "PTTL on servers 2.8 and after return -2 when the key doesn't exist" assert r.pttl('a') == -2 + @skip_if_server_version_lt('6.2.0') + def test_hrandfield(self, r): + assert r.hrandfield('key') is None + r.hset('key', mapping={'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5}) + assert r.hrandfield('key') is not None + assert len(r.hrandfield('key', 2)) == 2 + # with values + assert len(r.hrandfield('key', 2, True)) == 4 + # without duplications + assert len(r.hrandfield('key', 10)) == 5 + # with duplications + assert len(r.hrandfield('key', -10)) == 10 + def test_randomkey(self, r): assert r.randomkey() is None for key in ('a', 'b', 'c'): |