44import  pytest 
55
66from  redisvl .redis .connection  import  RedisConnectionFactory 
7+ from  redisvl .utils .utils  import  assert_no_warnings 
78
89
910class  DummyAsyncClient :
@@ -15,68 +16,55 @@ async def echo(self, *args, **kwargs):
1516
1617
1718@pytest .mark .asyncio  
18- async  def  test__get_aredis_connection_deprecates_url_kwarg_only (caplog ):
19+ async  def  test__get_aredis_connection_deprecates_url_kwarg_only ():
1920    # Patch AsyncRedis.from_url to avoid real network calls 
2021    with  patch (
2122        "redisvl.redis.connection.AsyncRedis.from_url" , return_value = DummyAsyncClient ()
2223    ):
23-         caplog . set_level ( logging . WARNING ,  logger = "redisvl.redis.connection" ) 
24-         await  RedisConnectionFactory ._get_aredis_connection (
25-             url = "redis://localhost:6379" 
26-         )
24+         with   pytest . warns ( DeprecationWarning )  as   record : 
25+              await  RedisConnectionFactory ._get_aredis_connection (
26+                  url = "redis://localhost:6379" 
27+              )
2728
28-     assert  (
29-         "The `url` parameter is deprecated. Please use `redis_url` instead." 
30-         in  caplog .text 
29+     assert  any (
30+         str (w .message )
31+         ==  (
32+             "Argument url is deprecated and will be removed in the next major release. " 
33+             "Use redis_url instead." 
34+         )
35+         for  w  in  record 
3136    )
3237
3338
3439@pytest .mark .asyncio  
35- async  def  test__get_aredis_connection_no_deprecation_with_redis_url (caplog ):
40+ async  def  test__get_aredis_connection_no_deprecation_with_redis_url ():
3641    # Patch AsyncRedis.from_url to avoid real network calls 
3742    with  patch (
3843        "redisvl.redis.connection.AsyncRedis.from_url" , return_value = DummyAsyncClient ()
3944    ):
40-         caplog .set_level (logging .WARNING , logger = "redisvl.redis.connection" )
41-         await  RedisConnectionFactory ._get_aredis_connection (
42-             redis_url = "redis://localhost:6379" 
43-         )
44- 
45-     assert  (
46-         "The `url` parameter is deprecated. Please use `redis_url` instead." 
47-         not  in caplog .text 
48-     )
45+         with  assert_no_warnings ():
46+             await  RedisConnectionFactory ._get_aredis_connection (
47+                 redis_url = "redis://localhost:6379" 
48+             )
4949
5050
51- def  test_get_async_redis_connection_deprecates_url_kwarg_only (caplog ):
51+ def  test_get_async_redis_connection_deprecates_url_kwarg_only ():
5252    # Patch AsyncRedis.from_url to avoid real network calls 
5353    with  patch (
5454        "redisvl.redis.connection.AsyncRedis.from_url" , return_value = MagicMock ()
5555    ):
56-         caplog .set_level (logging .WARNING , logger = "redisvl.redis.connection" )
5756        with  pytest .warns (DeprecationWarning ):
5857            RedisConnectionFactory .get_async_redis_connection (
5958                url = "redis://localhost:6379" 
6059            )
6160
62-     assert  (
63-         "The `url` parameter is deprecated. Please use `redis_url` instead." 
64-         in  caplog .text 
65-     )
66- 
6761
68- def  test_get_async_redis_connection_no_deprecation_with_redis_url (caplog ):
62+ def  test_get_async_redis_connection_no_deprecation_with_redis_url ():
6963    # Patch AsyncRedis.from_url to avoid real network calls 
7064    with  patch (
7165        "redisvl.redis.connection.AsyncRedis.from_url" , return_value = MagicMock ()
7266    ):
73-         caplog .set_level (logging .WARNING , logger = "redisvl.redis.connection" )
7467        with  pytest .warns (DeprecationWarning ):
7568            RedisConnectionFactory .get_async_redis_connection (
7669                redis_url = "redis://localhost:6379" 
7770            )
78- 
79-     assert  (
80-         "The `url` parameter is deprecated. Please use `redis_url` instead." 
81-         not  in caplog .text 
82-     )
0 commit comments