jamesls/fakeredis

flushall() doesn't clean everything

kedder opened this issue · 2 comments

When database contains expired keys, flushall() doesn't completely clean the database:

Python 2.7.14 (default, Sep 23 2017, 22:06:14) 
[GCC 7.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import fakeredis
>>> r = fakeredis.FakeStrictRedis()
>>> r.set('test', 1)
True
>>> r.set('test2', 2)
True
>>> r.expire('test', -1)
True
>>> r.flushall()
True
>>> r.get('test2')
'2'

The last sentece is expected to return None, because flushall() was executed before. However it left the test2 value around.

I think this is a side-effect of #135 plus the way MutableMapping implements clear. I'm working on a fix now.

Fixed in 39553dc.