Handle bool values in state

This commit is contained in:
simon987 2021-01-10 21:26:34 -05:00
parent b2efaa99a4
commit 58d150279f
3 changed files with 17 additions and 1 deletions

View File

@ -162,6 +162,8 @@ def _serialize(value):
return base64.b64encode(value)
if value is None:
return None
if isinstance(value, bool):
return value
return str(value)

View File

@ -2,7 +2,7 @@ from setuptools import setup
setup(
name="hexlib",
version="1.21",
version="1.22",
description="Misc utility methods",
author="simon987",
author_email="me@simon987.net",

View File

@ -61,3 +61,17 @@ class TestPersistentState(TestCase):
val["id"] = 1
self.assertDictEqual(val, s["a"][1])
def test_bool(self):
s = PersistentState()
val = {"a": True, "b": False}
s["a"][1] = val
s["a"][1] = {
"a": True
}
val["a"] = True
val["id"] = 1
self.assertDictEqual(val, s["a"][1])