summaryrefslogtreecommitdiff
path: root/tests/test_pipeline.py
diff options
context:
space:
mode:
authorAndy McCurdy <andy@andymccurdy.com>2019-12-29 12:16:50 -0800
committerAndy McCurdy <andy@andymccurdy.com>2019-12-29 12:16:50 -0800
commit8b76019c7d6b2eaa543e5dbf16c050cc6155efb1 (patch)
tree1373a358d103ebeae97774a3577b61b0eca0c2f2 /tests/test_pipeline.py
parent8df8cd54d135380ad8b3b8807a67a3e6915b0b49 (diff)
downloadredis-py-8b76019c7d6b2eaa543e5dbf16c050cc6155efb1.tar.gz
Testing the boolean nature of Pipeline instance should always return True.
Prior to this, pipeline instances used __len__() which returns the number of queued commands on the pipeline. When there were no queued commands, the pipeline instance would evaluate to 0 or False. Fixes #994
Diffstat (limited to 'tests/test_pipeline.py')
-rw-r--r--tests/test_pipeline.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/tests/test_pipeline.py b/tests/test_pipeline.py
index 264a64f..08b7fba 100644
--- a/tests/test_pipeline.py
+++ b/tests/test_pipeline.py
@@ -6,6 +6,11 @@ from redis._compat import unichr, unicode
class TestPipeline(object):
+ def test_pipeline_is_true(self, r):
+ "Ensure pipeline instances are not false-y"
+ with r.pipeline() as pipe:
+ assert pipe
+
def test_pipeline(self, r):
with r.pipeline() as pipe:
(pipe.set('a', 'a1')
@@ -28,17 +33,14 @@ class TestPipeline(object):
with r.pipeline() as pipe:
# Initially empty.
assert len(pipe) == 0
- assert not pipe
# Fill 'er up!
pipe.set('a', 'a1').set('b', 'b1').set('c', 'c1')
assert len(pipe) == 3
- assert pipe
# Execute calls reset(), so empty once again.
pipe.execute()
assert len(pipe) == 0
- assert not pipe
def test_pipeline_no_transaction(self, r):
with r.pipeline(transaction=False) as pipe: