Skip to content

Commit 46a8269

Browse files
committed
Fix test if redis is not loaded
handle the KeyError from trying to remove redis from sys.modules if it not loaded.
1 parent c34f002 commit 46a8269

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

test/test_config.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,12 @@ def testLoadSessionDb(self):
814814
config.SESSIONDB_BACKEND = "redis"
815815

816816
# make it looks like redis is not available
817-
del(sys.modules['redis'])
817+
try:
818+
del(sys.modules['redis'])
819+
except KeyError:
820+
# redis is not available anyway.
821+
pass
822+
818823
sys.modules['redis'] = None
819824
with self.assertRaises(configuration.OptionValueError) as cm:
820825
config.validator(config.options)

0 commit comments

Comments
 (0)