File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -1201,6 +1201,10 @@ async def reset(self):
1201
1201
await self .connection_pool .release (self .connection )
1202
1202
self .connection = None
1203
1203
1204
+ async def aclose (self ) -> None :
1205
+ """Alias for reset(), a standard method name for cleanup"""
1206
+ await self .reset ()
1207
+
1204
1208
def multi (self ):
1205
1209
"""
1206
1210
Start a transactional block of the pipeline after WATCH commands
Original file line number Diff line number Diff line change 2
2
import redis
3
3
from tests .conftest import skip_if_server_version_lt
4
4
5
+ from .compat import aclosing , mock
5
6
from .conftest import wait_for_command
6
7
7
8
@@ -286,6 +287,24 @@ async def test_watch_reset_unwatch(self, r):
286
287
assert unwatch_command is not None
287
288
assert unwatch_command ["command" ] == "UNWATCH"
288
289
290
+ @pytest .mark .onlynoncluster
291
+ async def test_aclose_is_reset (self , r ):
292
+ async with r .pipeline () as pipe :
293
+ called = 0
294
+
295
+ async def mock_reset ():
296
+ nonlocal called
297
+ called += 1
298
+
299
+ with mock .patch .object (pipe , "reset" , mock_reset ):
300
+ await pipe .aclose ()
301
+ assert called == 1
302
+
303
+ @pytest .mark .onlynoncluster
304
+ async def test_aclosing (self , r ):
305
+ async with aclosing (r .pipeline ()):
306
+ pass
307
+
289
308
@pytest .mark .onlynoncluster
290
309
async def test_transaction_callable (self , r ):
291
310
await r .set ("a" , 1 )
You can’t perform that action at this time.
0 commit comments