mirror of
https://github.com/simon987/hexlib.git
synced 2025-04-20 02:06:42 +00:00
Handle null values in state
This commit is contained in:
parent
b845d96295
commit
b2efaa99a4
@ -160,6 +160,8 @@ def _sqlite_type(value):
|
|||||||
def _serialize(value):
|
def _serialize(value):
|
||||||
if isinstance(value, bytes):
|
if isinstance(value, bytes):
|
||||||
return base64.b64encode(value)
|
return base64.b64encode(value)
|
||||||
|
if value is None:
|
||||||
|
return None
|
||||||
return str(value)
|
return str(value)
|
||||||
|
|
||||||
|
|
||||||
|
2
setup.py
2
setup.py
@ -2,7 +2,7 @@ from setuptools import setup
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="hexlib",
|
name="hexlib",
|
||||||
version="1.20",
|
version="1.21",
|
||||||
description="Misc utility methods",
|
description="Misc utility methods",
|
||||||
author="simon987",
|
author="simon987",
|
||||||
author_email="me@simon987.net",
|
author_email="me@simon987.net",
|
||||||
|
@ -47,3 +47,17 @@ class TestPersistentState(TestCase):
|
|||||||
val["id"] = 1
|
val["id"] = 1
|
||||||
|
|
||||||
self.assertDictEqual(val, s["a"][1])
|
self.assertDictEqual(val, s["a"][1])
|
||||||
|
|
||||||
|
def test_none(self):
|
||||||
|
s = PersistentState()
|
||||||
|
|
||||||
|
val = {"a": 1, "b": None}
|
||||||
|
s["a"][1] = val
|
||||||
|
s["a"][1] = {
|
||||||
|
"a": None
|
||||||
|
}
|
||||||
|
|
||||||
|
val["a"] = None
|
||||||
|
val["id"] = 1
|
||||||
|
|
||||||
|
self.assertDictEqual(val, s["a"][1])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user