Skip to content

Commit 18775ca

Browse files
committed
fix linting issues
1 parent e35e559 commit 18775ca

File tree

2 files changed

+54
-81
lines changed

2 files changed

+54
-81
lines changed

tests/test_asyncio/test_commands.py

Lines changed: 37 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -882,117 +882,90 @@ async def test_bitop_string_operands(self, r: redis.Redis):
882882
@pytest.mark.onlynoncluster
883883
@skip_if_server_version_lt("8.2.0")
884884
async def test_bitop_diff(self, r: redis.Redis):
885-
"""Test BITOP DIFF operation"""
886-
# Set up test data: a=0b11110000, b=0b11000000, c=0b10000000
887-
await r.set("a", b"\xf0") # 11110000
888-
await r.set("b", b"\xc0") # 11000000
889-
await r.set("c", b"\x80") # 10000000
885+
await r.set("a", b"\xf0")
886+
await r.set("b", b"\xc0")
887+
await r.set("c", b"\x80")
890888

891-
# DIFF: a AND NOT(b OR c) = 11110000 AND NOT(11000000) = 11110000 AND 00111111 = 00110000
892889
result = await r.bitop("DIFF", "result", "a", "b", "c")
893-
assert result == 1 # Length of result
894-
assert await r.get("result") == b"\x30" # 00110000
890+
assert result == 1
891+
assert await r.get("result") == b"\x30"
895892

896-
# Test with non-existent keys
897893
await r.bitop("DIFF", "result2", "a", "nonexistent")
898-
assert await r.get("result2") == b"\xf0" # Should be same as 'a'
894+
assert await r.get("result2") == b"\xf0"
899895

900896
@pytest.mark.onlynoncluster
901897
@skip_if_server_version_lt("8.2.0")
902898
async def test_bitop_diff1(self, r: redis.Redis):
903-
"""Test BITOP DIFF1 operation"""
904-
# Set up test data: a=0b11110000, b=0b11000000, c=0b10000000
905-
await r.set("a", b"\xf0") # 11110000
906-
await r.set("b", b"\xc0") # 11000000
907-
await r.set("c", b"\x80") # 10000000
899+
await r.set("a", b"\xf0")
900+
await r.set("b", b"\xc0")
901+
await r.set("c", b"\x80")
908902

909-
# DIFF1: NOT(a) AND (b OR c) = NOT(11110000) AND (11000000) = 00001111 AND 11000000 = 00000000
910903
result = await r.bitop("DIFF1", "result", "a", "b", "c")
911-
assert result == 1 # Length of result
912-
assert await r.get("result") == b"\x00" # 00000000
904+
assert result == 1
905+
assert await r.get("result") == b"\x00"
913906

914-
# Test with different data where result is non-zero
915-
await r.set("d", b"\x0f") # 00001111
916-
await r.set("e", b"\x03") # 00000011
917-
# DIFF1: NOT(d) AND e = NOT(00001111) AND 00000011 = 11110000 AND 00000011 = 00000000
907+
await r.set("d", b"\x0f")
908+
await r.set("e", b"\x03")
918909
await r.bitop("DIFF1", "result2", "d", "e")
919910
assert await r.get("result2") == b"\x00"
920911

921912
@pytest.mark.onlynoncluster
922913
@skip_if_server_version_lt("8.2.0")
923914
async def test_bitop_andor(self, r: redis.Redis):
924-
"""Test BITOP ANDOR operation"""
925-
# Set up test data: a=0b11110000, b=0b11000000, c=0b10000000
926-
await r.set("a", b"\xf0") # 11110000
927-
await r.set("b", b"\xc0") # 11000000
928-
await r.set("c", b"\x80") # 10000000
915+
await r.set("a", b"\xf0")
916+
await r.set("b", b"\xc0")
917+
await r.set("c", b"\x80")
929918

930-
# ANDOR: a AND (b OR c) = 11110000 AND (11000000) = 11110000 AND 11000000 = 11000000
931919
result = await r.bitop("ANDOR", "result", "a", "b", "c")
932-
assert result == 1 # Length of result
933-
assert await r.get("result") == b"\xc0" # 11000000
920+
assert result == 1
921+
assert await r.get("result") == b"\xc0"
934922

935-
# Test with non-overlapping bits
936-
await r.set("x", b"\xf0") # 11110000
937-
await r.set("y", b"\x0f") # 00001111
923+
await r.set("x", b"\xf0")
924+
await r.set("y", b"\x0f")
938925
await r.bitop("ANDOR", "result2", "x", "y")
939-
assert await r.get("result2") == b"\x00" # No overlap
926+
assert await r.get("result2") == b"\x00"
940927

941928
@pytest.mark.onlynoncluster
942929
@skip_if_server_version_lt("8.2.0")
943930
async def test_bitop_one(self, r: redis.Redis):
944-
"""Test BITOP ONE operation"""
945-
# Set up test data: a=0b11110000, b=0b11000000, c=0b10000000
946-
await r.set("a", b"\xf0") # 11110000
947-
await r.set("b", b"\xc0") # 11000000
948-
await r.set("c", b"\x80") # 10000000
949-
950-
# ONE: bits set in exactly one key
951-
# Position analysis:
952-
# Bit 7: a=1, b=1, c=1 -> count=3 -> not included
953-
# Bit 6: a=1, b=1, c=0 -> count=2 -> not included
954-
# Bit 5: a=1, b=0, c=0 -> count=1 -> included
955-
# Bit 4: a=1, b=0, c=0 -> count=1 -> included
956-
# Expected result: 00110000 = 0x30
931+
await r.set("a", b"\xf0")
932+
await r.set("b", b"\xc0")
933+
await r.set("c", b"\x80")
934+
957935
result = await r.bitop("ONE", "result", "a", "b", "c")
958-
assert result == 1 # Length of result
959-
assert await r.get("result") == b"\x30" # 00110000
936+
assert result == 1
937+
assert await r.get("result") == b"\x30"
960938

961-
# Test with two keys (should be equivalent to XOR)
962-
await r.set("x", b"\xf0") # 11110000
963-
await r.set("y", b"\x0f") # 00001111
939+
await r.set("x", b"\xf0")
940+
await r.set("y", b"\x0f")
964941
await r.bitop("ONE", "result2", "x", "y")
965-
assert await r.get("result2") == b"\xff" # 11111111 (XOR result)
942+
assert await r.get("result2") == b"\xff"
966943

967944
@pytest.mark.onlynoncluster
968945
@skip_if_server_version_lt("8.2.0")
969946
async def test_bitop_new_operations_with_empty_keys(self, r: redis.Redis):
970-
"""Test new BITOP operations with empty/non-existent keys"""
971-
await r.set("a", b"\xff") # 11111111
947+
await r.set("a", b"\xff")
972948

973-
# Test with empty destination
974949
await r.bitop("DIFF", "empty_result", "nonexistent", "a")
975-
assert await r.get("empty_result") is None
950+
assert await r.get("empty_result") == b"\x00"
976951

977952
await r.bitop("DIFF1", "empty_result2", "a", "nonexistent")
978-
assert await r.get("empty_result2") is None
953+
assert await r.get("empty_result2") == b"\x00"
979954

980955
await r.bitop("ANDOR", "empty_result3", "a", "nonexistent")
981-
assert await r.get("empty_result3") is None
956+
assert await r.get("empty_result3") == b"\x00"
982957

983958
await r.bitop("ONE", "empty_result4", "nonexistent")
984959
assert await r.get("empty_result4") is None
985960

986961
@pytest.mark.onlynoncluster
987962
@skip_if_server_version_lt("8.2.0")
988963
async def test_bitop_new_operations_return_values(self, r: redis.Redis):
989-
"""Test that new BITOP operations return correct length values"""
990-
await r.set("a", b"\xff\x00\xff") # 3 bytes
991-
await r.set("b", b"\x00\xff") # 2 bytes
964+
await r.set("a", b"\xff\x00\xff")
965+
await r.set("b", b"\x00\xff")
992966

993-
# All operations should return the length of the result string
994967
result1 = await r.bitop("DIFF", "result1", "a", "b")
995-
assert result1 == 3 # Length of longest input
968+
assert result1 == 3
996969

997970
result2 = await r.bitop("DIFF1", "result2", "a", "b")
998971
assert result2 == 3

tests/test_commands.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,8 +1316,8 @@ def test_bitop_string_operands(self, r):
13161316
@pytest.mark.onlynoncluster
13171317
@skip_if_server_version_lt("8.2.0")
13181318
def test_bitop_diff(self, r):
1319-
r["a"] = b"\xf0"
1320-
r["b"] = b"\xc0"
1319+
r["a"] = b"\xf0"
1320+
r["b"] = b"\xc0"
13211321
r["c"] = b"\x80"
13221322

13231323
result = r.bitop("DIFF", "result", "a", "b", "c")
@@ -1330,32 +1330,32 @@ def test_bitop_diff(self, r):
13301330
@pytest.mark.onlynoncluster
13311331
@skip_if_server_version_lt("8.2.0")
13321332
def test_bitop_diff1(self, r):
1333-
r["a"] = b"\xf0"
1334-
r["b"] = b"\xc0"
1335-
r["c"] = b"\x80"
1333+
r["a"] = b"\xf0"
1334+
r["b"] = b"\xc0"
1335+
r["c"] = b"\x80"
13361336

13371337
result = r.bitop("DIFF1", "result", "a", "b", "c")
13381338
assert result == 1
13391339
assert r["result"] == b"\x00"
13401340

1341-
r["d"] = b"\x0f"
1341+
r["d"] = b"\x0f"
13421342
r["e"] = b"\x03"
13431343
r.bitop("DIFF1", "result2", "d", "e")
13441344
assert r["result2"] == b"\x00"
13451345

13461346
@pytest.mark.onlynoncluster
13471347
@skip_if_server_version_lt("8.2.0")
13481348
def test_bitop_andor(self, r):
1349-
r["a"] = b"\xf0"
1350-
r["b"] = b"\xc0"
1351-
r["c"] = b"\x80"
1349+
r["a"] = b"\xf0"
1350+
r["b"] = b"\xc0"
1351+
r["c"] = b"\x80"
13521352

13531353
result = r.bitop("ANDOR", "result", "a", "b", "c")
1354-
assert result == 1
1355-
assert r["result"] == b"\xc0"
1354+
assert result == 1
1355+
assert r["result"] == b"\xc0"
13561356

1357-
r["x"] = b"\xf0"
1358-
r["y"] = b"\x0f"
1357+
r["x"] = b"\xf0"
1358+
r["y"] = b"\x0f"
13591359
r.bitop("ANDOR", "result2", "x", "y")
13601360
assert r["result2"] == b"\x00"
13611361

@@ -1371,7 +1371,7 @@ def test_bitop_one(self, r):
13711371
assert r["result"] == b"\x30"
13721372

13731373
r["x"] = b"\xf0"
1374-
r["y"] = b"\x0f"
1374+
r["y"] = b"\x0f"
13751375
r.bitop("ONE", "result2", "x", "y")
13761376
assert r["result2"] == b"\xff"
13771377

@@ -1381,13 +1381,13 @@ def test_bitop_new_operations_with_empty_keys(self, r):
13811381
r["a"] = b"\xff"
13821382

13831383
r.bitop("DIFF", "empty_result", "nonexistent", "a")
1384-
assert r.get("empty_result") is None
1384+
assert r.get("empty_result") == b"\x00"
13851385

13861386
r.bitop("DIFF1", "empty_result2", "a", "nonexistent")
1387-
assert r.get("empty_result2") is None
1387+
assert r.get("empty_result2") == b"\x00"
13881388

13891389
r.bitop("ANDOR", "empty_result3", "a", "nonexistent")
1390-
assert r.get("empty_result3") is None
1390+
assert r.get("empty_result3") == b"\x00"
13911391

13921392
r.bitop("ONE", "empty_result4", "nonexistent")
13931393
assert r.get("empty_result4") is None

0 commit comments

Comments
 (0)