MCPcopy
hub / github.com/redis/redis-py / test_exec_error_in_response

Method test_exec_error_in_response

tests/test_pipeline.py:94–121  ·  view source on GitHub ↗

an invalid pipeline command at exec time adds the exception instance to the list of returned values

(self, r)

Source from the content-addressed store, hash-verified

92 assert r["a"] == b"bad"
93
94 def test_exec_error_in_response(self, r):
95 """
96 an invalid pipeline command at exec time adds the exception instance
97 to the list of returned values
98 """
99 r["c"] = "a"
100 with r.pipeline() as pipe:
101 pipe.set("a", 1).set("b", 2).lpush("c", 3).set("d", 4)
102 result = pipe.execute(raise_on_error=False)
103
104 assert result[0]
105 assert r["a"] == b"1"
106 assert result[1]
107 assert r["b"] == b"2"
108
109 # we can't lpush to a key that's a string value, so this should
110 # be a ResponseError exception
111 assert isinstance(result[2], redis.ResponseError)
112 assert r["c"] == b"a"
113
114 # since this isn't a transaction, the other commands after the
115 # error are still executed
116 assert result[3]
117 assert r["d"] == b"4"
118
119 # make sure the pipe was restored to a working state
120 assert pipe.set("z", "zzz").execute() == [True]
121 assert r["z"] == b"zzz"
122
123 def test_exec_error_raised(self, r):
124 r["c"] = "a"

Callers

nothing calls this directly

Calls 4

lpushMethod · 0.80
pipelineMethod · 0.45
setMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected