@@ -146,7 +146,6 @@ async def get_mocked_redis_client(
146
146
with mock .patch .object (ClusterNode , "execute_command" ) as execute_command_mock :
147
147
148
148
async def execute_command (* _args , ** _kwargs ):
149
-
150
149
if _args [0 ] == "CLUSTER SLOTS" :
151
150
if cluster_slots_raise_error :
152
151
raise ResponseError ()
@@ -1577,23 +1576,23 @@ async def test_cluster_bitop_not_empty_string(self, r: RedisCluster) -> None:
1577
1576
1578
1577
@skip_if_server_version_lt ("2.6.0" )
1579
1578
async def test_cluster_bitop_not (self , r : RedisCluster ) -> None :
1580
- test_str = b"\xAA \x00 \xFF \x55 "
1579
+ test_str = b"\xaa \x00 \xff \x55 "
1581
1580
correct = ~ 0xAA00FF55 & 0xFFFFFFFF
1582
1581
await r .set ("{foo}a" , test_str )
1583
1582
await r .bitop ("not" , "{foo}r" , "{foo}a" )
1584
1583
assert int (binascii .hexlify (await r .get ("{foo}r" )), 16 ) == correct
1585
1584
1586
1585
@skip_if_server_version_lt ("2.6.0" )
1587
1586
async def test_cluster_bitop_not_in_place (self , r : RedisCluster ) -> None :
1588
- test_str = b"\xAA \x00 \xFF \x55 "
1587
+ test_str = b"\xaa \x00 \xff \x55 "
1589
1588
correct = ~ 0xAA00FF55 & 0xFFFFFFFF
1590
1589
await r .set ("{foo}a" , test_str )
1591
1590
await r .bitop ("not" , "{foo}a" , "{foo}a" )
1592
1591
assert int (binascii .hexlify (await r .get ("{foo}a" )), 16 ) == correct
1593
1592
1594
1593
@skip_if_server_version_lt ("2.6.0" )
1595
1594
async def test_cluster_bitop_single_string (self , r : RedisCluster ) -> None :
1596
- test_str = b"\x01 \x02 \xFF "
1595
+ test_str = b"\x01 \x02 \xff "
1597
1596
await r .set ("{foo}a" , test_str )
1598
1597
await r .bitop ("and" , "{foo}res1" , "{foo}a" )
1599
1598
await r .bitop ("or" , "{foo}res2" , "{foo}a" )
@@ -1604,8 +1603,8 @@ async def test_cluster_bitop_single_string(self, r: RedisCluster) -> None:
1604
1603
1605
1604
@skip_if_server_version_lt ("2.6.0" )
1606
1605
async def test_cluster_bitop_string_operands (self , r : RedisCluster ) -> None :
1607
- await r .set ("{foo}a" , b"\x01 \x02 \xFF \xFF " )
1608
- await r .set ("{foo}b" , b"\x01 \x02 \xFF " )
1606
+ await r .set ("{foo}a" , b"\x01 \x02 \xff \xff " )
1607
+ await r .set ("{foo}b" , b"\x01 \x02 \xff " )
1609
1608
await r .bitop ("and" , "{foo}res1" , "{foo}a" , "{foo}b" )
1610
1609
await r .bitop ("or" , "{foo}res2" , "{foo}a" , "{foo}b" )
1611
1610
await r .bitop ("xor" , "{foo}res3" , "{foo}a" , "{foo}b" )
@@ -2803,6 +2802,25 @@ async def test_asking_error(self, r: RedisCluster) -> None:
2803
2802
assert ask_node ._free .pop ().read_response .await_count
2804
2803
assert res == ["MOCK_OK" ]
2805
2804
2805
+ async def test_error_is_truncated (self , r ) -> None :
2806
+ """
2807
+ Test that an error from the pipeline is truncated correctly.
2808
+ """
2809
+ key = "a" * 5000
2810
+
2811
+ async with r .pipeline () as pipe :
2812
+ pipe .set (key , 1 )
2813
+ pipe .llen (key )
2814
+ pipe .expire (key , 100 )
2815
+
2816
+ with pytest .raises (Exception ) as ex :
2817
+ await pipe .execute ()
2818
+
2819
+ expected = (
2820
+ "Command # 2 (LLEN " + ("a" * 92 ) + "...) of pipeline caused error: "
2821
+ )
2822
+ assert str (ex .value ).startswith (expected )
2823
+
2806
2824
async def test_moved_redirection_on_slave_with_default (
2807
2825
self , r : RedisCluster
2808
2826
) -> None :
0 commit comments