Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix getitem syntax for redis get when value is the empty string #679

Merged
merged 1 commit into from
Nov 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion redis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ def __getitem__(self, name):
doesn't exist.
"""
value = self.get(name)
if value:
if value is not None:
return value
raise KeyError(name)

Expand Down
4 changes: 4 additions & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,10 @@ def test_getitem_raises_keyerror_for_missing_key(self, r):
with pytest.raises(KeyError):
r['a']

def test_getitem_does_not_raise_keyerror_for_empty_string(self, r):
r['a'] = b("")
assert r['a'] == b("")

def test_get_set_bit(self, r):
# no value
assert not r.getbit('a', 5)
Expand Down