Skip to content

__delitem__ missing #223

@viljoviitanen

Description

@viljoviitanen

Noticed fakeredis does not support "del" operator, i.e. it does not implement __delitem__ , while real redis does.

So code like this works on real redis:

import redis
r = redis.StrictRedis(host='localhost', port=6379, db=0)
r['foo'] = 'bar'
print (r['foo'])  #bar
del r['foo']
print (r['foo'])  #KeyError: 'foo'

but fails on fakeredis:

import fakeredis
r = fakeredis.FakeStrictRedis()
r['foo'] = 'bar'
print (r['foo'])  #bar
del r['foo']      #AttributeError: __delitem__
#r.delete('foo')  #this would work

My guess on this is that even if __delitem__ is there in _StrKeyDict, because of name mangling, this happens.

If there's interest in getting this fixed, I can probably do a clean enough PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions