summaryrefslogtreecommitdiff
path: root/tests/test_commands.py
diff options
context:
space:
mode:
authordvora-h <67596500+dvora-h@users.noreply.github.com>2022-04-04 13:06:01 +0300
committerGitHub <noreply@github.com>2022-04-04 13:06:01 +0300
commitd4fcd999b7206b7960f0aa01d8f5c71b699df491 (patch)
treeabf20d8acb44677c3970b56a7764d0357859d6b2 /tests/test_commands.py
parent7b7c6c8867a66493c51ed6525c6a0863f437f530 (diff)
downloadredis-py-d4fcd999b7206b7960f0aa01d8f5c71b699df491.tar.gz
Add support for BIT|BYTE option (#2068)
* Add support for BIT|BYTE option * linters
Diffstat (limited to 'tests/test_commands.py')
-rw-r--r--tests/test_commands.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_commands.py b/tests/test_commands.py
index a0d57f0..de94539 100644
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -863,6 +863,15 @@ class TestRedisCommands:
assert r.bitcount("a", -2, -1) == 2
assert r.bitcount("a", 1, 1) == 1
+ @skip_if_server_version_lt("7.0.0")
+ def test_bitcount_mode(self, r):
+ r.set("mykey", "foobar")
+ assert r.bitcount("mykey") == 26
+ assert r.bitcount("mykey", 1, 1, "byte") == 6
+ assert r.bitcount("mykey", 5, 30, "bit") == 17
+ with pytest.raises(redis.ResponseError):
+ assert r.bitcount("mykey", 5, 30, "but")
+
@pytest.mark.onlynoncluster
@skip_if_server_version_lt("2.6.0")
def test_bitop_not_empty_string(self, r):
@@ -935,6 +944,15 @@ class TestRedisCommands:
with pytest.raises(exceptions.RedisError):
r.bitpos(key, 7) == 12
+ @skip_if_server_version_lt("7.0.0")
+ def test_bitpos_mode(self, r):
+ r.set("mykey", b"\x00\xff\xf0")
+ assert r.bitpos("mykey", 1, 0) == 8
+ assert r.bitpos("mykey", 1, 2, -1, "byte") == 16
+ assert r.bitpos("mykey", 0, 7, 15, "bit") == 7
+ with pytest.raises(redis.ResponseError):
+ r.bitpos("mykey", 1, 7, 15, "bite")
+
@pytest.mark.onlynoncluster
@skip_if_server_version_lt("6.2.0")
def test_copy(self, r):