Do not update correctmap if state is invaid.
This commit is contained in:
@@ -91,8 +91,11 @@ class CorrectMap(object):
|
||||
# empty current dict
|
||||
self.__init__()
|
||||
|
||||
if not correct_map:
|
||||
return
|
||||
|
||||
# create new dict entries
|
||||
if correct_map and not isinstance(correct_map.values()[0], dict):
|
||||
if not isinstance(correct_map.values()[0], dict):
|
||||
# special migration
|
||||
for k in correct_map:
|
||||
self.set(k, correctness=correct_map[k])
|
||||
|
||||
@@ -215,3 +215,13 @@ class CorrectMapTest(unittest.TestCase):
|
||||
for invalid in invalid_list:
|
||||
with self.assertRaises(Exception):
|
||||
self.cmap.update(invalid)
|
||||
|
||||
def test_set_none_state(self):
|
||||
"""
|
||||
Test that if an invalid state is set to correct map, the state does not
|
||||
update at all.
|
||||
"""
|
||||
invalid_list = [None, "", False, 0]
|
||||
for invalid in invalid_list:
|
||||
self.cmap.set_dict(invalid)
|
||||
self.assertEqual(self.cmap.get_dict(), {})
|
||||
|
||||
Reference in New Issue
Block a user