File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -1192,6 +1192,10 @@ def reset(self):
1192
1192
self .connection_pool .release (self .connection )
1193
1193
self .connection = None
1194
1194
1195
+ def close (self ):
1196
+ """Close the pipeline"""
1197
+ self .reset ()
1198
+
1195
1199
def multi (self ):
1196
1200
"""
1197
1201
Start a transactional block of the pipeline after WATCH commands
Original file line number Diff line number Diff line change
1
+ from contextlib import closing
2
+ from unittest import mock
3
+
1
4
import pytest
2
5
import redis
3
6
@@ -284,6 +287,24 @@ def test_watch_reset_unwatch(self, r):
284
287
assert unwatch_command is not None
285
288
assert unwatch_command ["command" ] == "UNWATCH"
286
289
290
+ @pytest .mark .onlynoncluster
291
+ def test_close_is_reset (self , r ):
292
+ with r .pipeline () as pipe :
293
+ called = 0
294
+
295
+ def mock_reset ():
296
+ nonlocal called
297
+ called += 1
298
+
299
+ with mock .patch .object (pipe , "reset" , mock_reset ):
300
+ pipe .close ()
301
+ assert called == 1
302
+
303
+ @pytest .mark .onlynoncluster
304
+ def test_closing (self , r ):
305
+ with closing (r .pipeline ()):
306
+ pass
307
+
287
308
@pytest .mark .onlynoncluster
288
309
def test_transaction_callable (self , r ):
289
310
r ["a" ] = 1
You can’t perform that action at this time.
0 commit comments