Use dbsize() to test for empty Redis database

This commit is contained in:
Selwin Ong 2018-05-01 07:20:45 +07:00
parent bc8d4a087a
commit 63a04d275e
1 changed files with 1 additions and 1 deletions

View File

@ -20,7 +20,7 @@ def find_empty_redis_database():
""" """
for dbnum in range(4, 17): for dbnum in range(4, 17):
testconn = StrictRedis(db=dbnum) testconn = StrictRedis(db=dbnum)
empty = len(testconn.keys('*')) == 0 empty = testconn.dbsize() == 0
if empty: if empty:
return testconn return testconn
assert False, 'No empty Redis database found to run tests in.' assert False, 'No empty Redis database found to run tests in.'