diff options
-rwxr-xr-x | redis/client.py | 14 | ||||
-rw-r--r-- | tests/test_commands.py | 5 |
2 files changed, 11 insertions, 8 deletions
diff --git a/redis/client.py b/redis/client.py index 0383d14..49cb204 100755 --- a/redis/client.py +++ b/redis/client.py @@ -1152,17 +1152,16 @@ class Redis(object): Decrements the value of ``key`` by ``amount``. If no key exists, the value will be initialized as 0 - ``amount`` """ - return self.execute_command('DECRBY', name, amount) + # An alias for ``decr()``, because it is already implemented + # as DECRBY redis command. + return self.decrby(name, amount) def decrby(self, name, amount=1): """ Decrements the value of ``key`` by ``amount``. If no key exists, the value will be initialized as 0 - ``amount`` """ - - # An alias for ``decr()``, because it is already implemented - # as DECRBY redis command. - return self.decr(name, amount) + return self.execute_command('DECRBY', name, amount) def delete(self, *names): "Delete one or more keys specified by ``names``" @@ -1240,17 +1239,16 @@ class Redis(object): Increments the value of ``key`` by ``amount``. If no key exists, the value will be initialized as ``amount`` """ - return self.execute_command('INCRBY', name, amount) + return self.incrby(name, amount) def incrby(self, name, amount=1): """ Increments the value of ``key`` by ``amount``. If no key exists, the value will be initialized as ``amount`` """ - # An alias for ``incr()``, because it is already implemented # as INCRBY redis command. - return self.incr(name, amount) + return self.execute_command('INCRBY', name, amount) def incrbyfloat(self, name, amount=1.0): """ diff --git a/tests/test_commands.py b/tests/test_commands.py index 8a6be40..28b8813 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -301,6 +301,11 @@ class TestRedisCommands(object): assert r.decr('a', amount=5) == -7 assert r['a'] == b'-7' + def test_decrby(self, r): + assert r.decrby('a', amount=2) == -2 + assert r.decrby('a', amount=3) == -5 + assert r['a'] == b'-5' + def test_delete(self, r): assert r.delete('a') == 0 r['a'] = 'foo' |