Skip to content

Commit

Permalink
Make sure fallback to the Redis module is working correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
dwighthubbard committed Nov 6, 2015
1 parent 8130242 commit 72f9f10
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion redislite/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def __init__(self, *args, **kwargs):
# If the user is specifying settings we can't configure just pass the
# request to the redis.Redis module
if 'host' in kwargs.keys() or 'port' in kwargs.keys():
super(RedisMixin, self).__init__(*args, **kwargs) # pragma: no cover
return super(RedisMixin, self).__init__(*args, **kwargs) # pragma: no cover

self.socket_file = kwargs.get('unix_socket_path', None)
if self.socket_file and self.socket_file == os.path.basename(self.socket_file):
Expand Down
11 changes: 11 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import stat
import tempfile
import unittest
from redis.exceptions import ConnectionError


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -268,6 +269,16 @@ def test_connection_count_multiple(self):
s = redislite.Redis(r.db)
self.assertEqual(r._connection_count(), 2)

def test_connection_fallthrough(self):
"""
Create a connection with an argument that will cause redislite
to pass it to the redis module. This should generate an exception
since there is no redis server running on the port.
:return:
"""
with self.assertRaises(ConnectionError):
redislite.Redis(port=1).keys()


if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG)
Expand Down

0 comments on commit 72f9f10

Please sign in to comment.