summaryrefslogtreecommitdiff
path: root/tests/test_pipeline.py
diff options
context:
space:
mode:
authorNick Gaya <nicholasgaya+github@gmail.com>2020-03-05 01:33:55 -0800
committerAndy McCurdy <andy@andymccurdy.com>2020-03-10 17:10:04 -0700
commit07fec7e18996b6b3b4f30ec9636b88c9b287ece5 (patch)
tree8fea4af74c1aba7cd6260cb4eb62ed35948e9e64 /tests/test_pipeline.py
parent81d76657385fc81548e5eaca4781c0e6b214ea16 (diff)
downloadredis-py-07fec7e18996b6b3b4f30ec9636b88c9b287ece5.tar.gz
Don't send DISCARD after ExecAbortError in pipeline
The `EXECABORT` error type was added in Redis 2.6.5 and is returned from an `EXEC` command to indicate that the transaction was aborted due to an invalid command. It is not necessary to call `DISCARD` after this error, and doing so causes a "DISCARD without MULTI" error.
Diffstat (limited to 'tests/test_pipeline.py')
-rw-r--r--tests/test_pipeline.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/test_pipeline.py b/tests/test_pipeline.py
index 828b989..088071b 100644
--- a/tests/test_pipeline.py
+++ b/tests/test_pipeline.py
@@ -172,6 +172,21 @@ class TestPipeline(object):
assert pipe.set('z', 'zzz').execute() == [True]
assert r['z'] == b'zzz'
+ def test_parse_error_raised_transaction(self, r):
+ with r.pipeline() as pipe:
+ pipe.multi()
+ # the zrem is invalid because we don't pass any keys to it
+ pipe.set('a', 1).zrem('b').set('b', 2)
+ with pytest.raises(redis.ResponseError) as ex:
+ pipe.execute()
+
+ assert unicode(ex.value).startswith('Command # 2 (ZREM b) of '
+ 'pipeline caused error: ')
+
+ # make sure the pipe was restored to a working state
+ assert pipe.set('z', 'zzz').execute() == [True]
+ assert r['z'] == b'zzz'
+
def test_watch_succeed(self, r):
r['a'] = 1
r['b'] = 2