diff options
Diffstat (limited to 'tests/test_pipeline.py')
-rw-r--r-- | tests/test_pipeline.py | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/tests/test_pipeline.py b/tests/test_pipeline.py index 1f3947e..a8941d7 100644 --- a/tests/test_pipeline.py +++ b/tests/test_pipeline.py @@ -1,8 +1,8 @@ -from __future__ import with_statement +from __future__ import unicode_literals import pytest import redis -from redis._compat import b, u, unichr, unicode +from redis._compat import unichr, unicode class TestPipeline(object): @@ -13,11 +13,11 @@ class TestPipeline(object): assert pipe.execute() == \ [ True, - b('a1'), + b'a1', True, True, 2.0, - [(b('z1'), 2.0), (b('z2'), 4)], + [(b'z1', 2.0), (b'z2', 4)], ] def test_pipeline_length(self, r): @@ -40,9 +40,9 @@ class TestPipeline(object): with r.pipeline(transaction=False) as pipe: pipe.set('a', 'a1').set('b', 'b1').set('c', 'c1') assert pipe.execute() == [True, True, True] - assert r['a'] == b('a1') - assert r['b'] == b('b1') - assert r['c'] == b('c1') + assert r['a'] == b'a1' + assert r['b'] == b'b1' + assert r['c'] == b'c1' def test_pipeline_no_transaction_watch(self, r): r['a'] = 0 @@ -70,7 +70,7 @@ class TestPipeline(object): with pytest.raises(redis.WatchError): pipe.execute() - assert r['a'] == b('bad') + assert r['a'] == b'bad' def test_exec_error_in_response(self, r): """ @@ -83,23 +83,23 @@ class TestPipeline(object): result = pipe.execute(raise_on_error=False) assert result[0] - assert r['a'] == b('1') + assert r['a'] == b'1' assert result[1] - assert r['b'] == b('2') + assert r['b'] == b'2' # we can't lpush to a key that's a string value, so this should # be a ResponseError exception assert isinstance(result[2], redis.ResponseError) - assert r['c'] == b('a') + assert r['c'] == b'a' # since this isn't a transaction, the other commands after the # error are still executed assert result[3] - assert r['d'] == b('4') + assert r['d'] == b'4' # make sure the pipe was restored to a working state assert pipe.set('z', 'zzz').execute() == [True] - assert r['z'] == b('zzz') + assert r['z'] == b'zzz' def test_exec_error_raised(self, r): r['c'] = 'a' @@ -112,7 +112,7 @@ class TestPipeline(object): # make sure the pipe was restored to a working state assert pipe.set('z', 'zzz').execute() == [True] - assert r['z'] == b('zzz') + assert r['z'] == b'zzz' def test_transaction_with_empty_error_command(self, r): """ @@ -154,7 +154,7 @@ class TestPipeline(object): # make sure the pipe was restored to a working state assert pipe.set('z', 'zzz').execute() == [True] - assert r['z'] == b('zzz') + assert r['z'] == b'zzz' def test_watch_succeed(self, r): r['a'] = 1 @@ -165,8 +165,8 @@ class TestPipeline(object): assert pipe.watching a_value = pipe.get('a') b_value = pipe.get('b') - assert a_value == b('1') - assert b_value == b('2') + assert a_value == b'1' + assert b_value == b'2' pipe.multi() pipe.set('c', 3) @@ -197,7 +197,7 @@ class TestPipeline(object): pipe.unwatch() assert not pipe.watching pipe.get('a') - assert pipe.execute() == [b('1')] + assert pipe.execute() == [b'1'] def test_transaction_callable(self, r): r['a'] = 1 @@ -206,9 +206,9 @@ class TestPipeline(object): def my_transaction(pipe): a_value = pipe.get('a') - assert a_value in (b('1'), b('2')) + assert a_value in (b'1', b'2') b_value = pipe.get('b') - assert b_value == b('2') + assert b_value == b'2' # silly run-once code... incr's "a" so WatchError should be raised # forcing this all to run again. this should incr "a" once to "2" @@ -221,7 +221,7 @@ class TestPipeline(object): result = r.transaction(my_transaction, 'a', 'b') assert result == [True] - assert r['c'] == b('4') + assert r['c'] == b'4' def test_exec_error_in_no_transaction_pipeline(self, r): r['a'] = 1 @@ -235,10 +235,10 @@ class TestPipeline(object): assert unicode(ex.value).startswith('Command # 1 (LLEN a) of ' 'pipeline caused error: ') - assert r['a'] == b('1') + assert r['a'] == b'1' def test_exec_error_in_no_transaction_pipeline_unicode_command(self, r): - key = unichr(3456) + u('abcd') + unichr(3421) + key = unichr(3456) + 'abcd' + unichr(3421) r[key] = 1 with r.pipeline(transaction=False) as pipe: pipe.llen(key) @@ -251,4 +251,4 @@ class TestPipeline(object): 'error: ') % key assert unicode(ex.value).startswith(expected) - assert r[key] == b('1') + assert r[key] == b'1' |