Allow the use of 'missing=None' for Number
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
Changes
|
||||
=======
|
||||
|
||||
Next release
|
||||
------------
|
||||
|
||||
- Allow the use of 'missing=None' for Number. See
|
||||
https://github.com/Pylons/colander/pull/59 .
|
||||
|
||||
0.9.8 (2012-04-27)
|
||||
------------------
|
||||
|
||||
|
@@ -951,7 +951,7 @@ class Number(SchemaType):
|
||||
num = None
|
||||
|
||||
def serialize(self, node, appstruct):
|
||||
if not appstruct:
|
||||
if appstruct in (null, None):
|
||||
return null
|
||||
|
||||
try:
|
||||
|
@@ -1192,6 +1192,13 @@ class TestInteger(unittest.TestCase):
|
||||
result = typ.serialize(node, val)
|
||||
self.assertEqual(result, '1')
|
||||
|
||||
def test_serialize_zero(self):
|
||||
val = 0
|
||||
node = DummySchemaNode(None)
|
||||
typ = self._makeOne()
|
||||
result = typ.serialize(node, val)
|
||||
self.assertEqual(result, '0')
|
||||
|
||||
class TestFloat(unittest.TestCase):
|
||||
def _makeOne(self):
|
||||
from colander import Float
|
||||
|
Reference in New Issue
Block a user