Allow use of 'None' as 'missing' for Numbers.

This commit is contained in:
philipp.thuerwaechter
2012-07-18 10:34:41 +02:00
parent ccd865d87c
commit 979cd65705
2 changed files with 9 additions and 1 deletions

View File

@@ -951,7 +951,7 @@ class Number(SchemaType):
num = None
def serialize(self, node, appstruct):
if appstruct is null:
if not appstruct:
return null
try:

View File

@@ -1148,6 +1148,14 @@ class TestInteger(unittest.TestCase):
result = typ.serialize(node, val)
self.assertEqual(result, colander.null)
def test_serialize_none(self):
import colander
val = None
node = DummySchemaNode(None)
typ = self._makeOne()
result = typ.serialize(node, val)
self.assertEqual(result, colander.null)
def test_serialize_emptystring(self):
import colander
val = ''